Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
First Unique Character in a String
Bookmark
Brute Force
Two-Pass Count
Streaming Queue
Input
Standard
Later Unique
No Unique
Custom
s
=
leetcode
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
no map — compare each character against every other
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
no map — compare each character against every other
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
is 'l' at index 0 unique? scan for a match
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[1] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[2] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[3] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[4] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[5] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[6] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
j
s[7] ≠ 'l', keep scanning
l
e
e
t
c
o
d
e
0
1
2
3
4
5
6
7
i
return
0
algo
master
.
io
Step:
For each character, scan the whole string for a duplicate
0 / 9
Input
Standard
Later Unique
No Unique
Custom
s
=
leetcode
0 / 9
algo
master
.
io
Step:
For each character, scan the whole string for a duplicate