#C4313. Index of First Unique Character
Index of First Unique Character
Index of First Unique Character
You are given a string s consisting of lowercase English letters. Your task is to find and output the index of the first character in s that does not repeat anywhere else in the string.
If no such character exists, output \( -1 \).
Note: The index is 0-based. Also, the string may contain up to 105 characters.
Example:
- For s = "leetcode", the result is 0 because 'l' appears only once.
- For s = "loveleetcode", the result is 2 because 'v' (at index 2) is the first unique character.
- For s = "aabb", the result is -1 since no character appears exactly once.
inputFormat
The input consists of a single line containing a non-empty string s of lowercase English letters.
outputFormat
Output a single integer which is the index of the first unique character in the input string s. If there is no unique character, output \( -1 \).
## sampleleetcode
0