30:00
Given a string s, find the first character that appears exactly once in it and return its index. If every character repeats, return -1.
1≤s.length≤1051 \leq s.\text{length} \leq 10^51≤s.length≤105
s consists of only lowercase English letters.
s
Run code to see results.
Two passes over "leetcode": first count every letter, then find the first one whose count is 1.
s (8 chars)
▼
0
1
2
3
4
5
6
7
tally board (count)
l
e
t
c
o
d
Given a lowercase string, return the index of the first character that appears exactly once. If every character repeats, return -1.