Learn
Practice
Interview
Resources
Newsletter
F
Toggle theme
0
F
0
Toggle menu
Animations
← Back to All Animations
Longest Word in Dictionary
Bookmark
Input
Example 1
Example 2
Example 3
Custom
words
=
[w, wo, wor, worl, world]
Phase
Initialization
Current Word
—
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
Phase
Initialization
Current Word
—
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
Phase
Phase 1: Building Trie
Inserting
"wo"
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
Phase
Phase 1: Building Trie
Inserting
"wor"
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
o
Phase
Phase 1: Building Trie
Inserting
"worl"
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
Phase
Phase 1: Building Trie
Inserting
"worl"
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
Phase
Phase 1: Building Trie
Inserting
"world"
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
Phase
Phase 2: DFS Search
DFS Path
—
Result (Longest Word)
""
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
d
Phase
Phase 2: DFS Search
DFS Path
"wor"
Result (Longest Word)
"wo"
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
d
Phase
Phase 2: DFS Search
DFS Path
"world"
Result (Longest Word)
"worl"
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
d
Phase
Complete
DFS Path
—
Result (Longest Word)
"world"
Default
Active
Visited
New / Skipped
End of Word
*
w
o
r
l
d
algo
master
.
io
Step:
Start: Build a Trie from words, then DFS to find the longest word where every prefix is also a word
0 / 63
Input
Example 1
Example 2
Example 3
Custom
words
=
[w, wo, wor, worl, world]
0 / 63
algo
master
.
io
Step:
Start: Build a Trie from words, then DFS to find the longest word where every prefix is also a word