first_unique_char_index(s) that returns the index of the first character in s that does not repeat anywhere else in the string. If every character repeats, return -1.s = 'leetcode'
0
'l' never appears again in the string, and it's the earliest such character.
s = 'aabb'
-1
Every character appears at least twice.
s = 'loveleetcode'
2
'v' at index 2 is the first character with a total count of 1.
First pass: build a full frequency count with a dictionary.
Second pass: return the first index whose character has count 1.