First Unique Character in a String Problem

First Unique Character in a String Problem — ExecCode School DSA Practice

Solve the First Unique Character in a String problem on ExecCode. Free online school DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given a string s, find the first non-repeating character in it and return its index. Your task is to solve First Unique Character in a String. If it does not exist, return -1.

Examples

Input leetcode; Output 0. Input loveleetcode; Output 2

Constraints

1 <= n <= 10^5

Practice First Unique Character in a String free on ExecCode. Browse DSA problems, topic map, and placement guides.