Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Find the Length of the Longest Common Prefix
Bookmark
Brute Force
Hash Set
Trie
Input
Example 1 (ans: 3)
Example 2 (ans: 0)
Example 3 (ans: 4)
Custom
arr1
=
[1, 10, 100]
,
arr2
=
[1000]
Phase
Compare every pair
Max Prefix Length
0
arr1
(3)
1
10
100
arr2
(1)
1000
Phase
Compare every pair
Max Prefix Length
0
arr1
(3)
1
10
100
arr2
(1)
1000
Phase
Compare every pair
Max Prefix Length
0
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
1
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
1
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
1
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
2
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
2
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
0
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
2
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
0
y
1
0
0
0
Phase
Compare every pair
Max Prefix Length
2
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
0
y
1
0
0
0
Phase
Complete
Max Prefix Length
3
arr1
(3)
1
10
100
arr2
(1)
1000
Digit comparison
x
1
0
0
y
1
0
0
0
algo
master
.
io
Step:
Start with a max prefix length of 0
0 / 22
Input
Example 1 (ans: 3)
Example 2 (ans: 0)
Example 3 (ans: 4)
Custom
arr1
=
[1, 10, 100]
,
arr2
=
[1000]
0 / 22
algo
master
.
io
Step:
Start with a max prefix length of 0