92. First Unique Character

Acceptance — 0 accepted 0 submissions

Medium
HashingStrings
No companies listed
In a lucky draw, the first participant whose name initial is not shared with anyone else wins.

Given a string of initials, find the index (0-based) of the first character that appears exactly once. If none exists, print -1.

Input Format
A single string of lowercase letters.

Output Format
Print the index of the first non-repeating character, or -1.

Constraints
• 1 ≤ length ≤ 10^5

Example 1

Input
leetcode
Output
0

Explanation l appears only once and comes first, so index 0.

Example 2

Input
loveleetcode
Output
2

Explanation v at index 2 is the first unique character.

Example 3

Input
aabb
Output
-1

Explanation Every character repeats.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
0
No results yet
Run your code to test it against the sample cases.
Problem List