Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Longest Common Prefix
Bookmark
Vertical Scan
Sorting
Divide and Conquer
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
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
prefix =
""
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
""
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
""
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
"f"
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
"f"
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
"fl"
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
"fl"
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
col
prefix =
"fl"
0
1
2
3
4
5
f
l
o
w
e
r
f
l
o
w
f
l
i
g
h
t
prefix =
"fl"
algo
master
.
io
Step:
Start: find the longest common prefix of 3 strings by scanning column by column
0 / 13
Input
Example 1
Example 2 (No Prefix)
Example 3 (Long)
All Same
Custom
strs
=
[flower, flow, flight]
0 / 13
algo
master
.
io
Step:
Start: find the longest common prefix of 3 strings by scanning column by column