Learn
Practice
Newsletter
Resources
F
Toggle theme
0
F
Toggle theme
0
Toggle menu
← Back to All Animations
Longest Common Prefix
Bookmark
Input
Example 1
Example 2 (No Prefix)
Example 3 (Long)
All Same
Custom
strs
=
[flower, flow, flight]
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
Prefix: ""
algo
master
.
io
Step:
Start: Find longest common prefix using vertical scanning
0 / 13
Input
Example 1
Example 2 (No Prefix)
Example 3 (Long)
All Same
Custom
strs
=
[flower, flow, flight]
0 / 13
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
Prefix: ""
algo
master
.
io
Step:
Start: Find longest common prefix using vertical scanning