Code
Loading editor...
Tap Analyze to see visualization
Click Analyze to visualize
See step-by-step execution, variables, and output
Variables
Run code to see variables
Output
Console output will appear here
Click Analyze to visualize
See step-by-step execution, variables, and output
Run code to see variables
Console output will appear here
Insert all roots in trie. For each word, walk characters until a terminal root node appears and replace immediately.
First terminal reached in the trie walk is the shortest matching root because we process from left to right in a single pass.
Updated Feb 2026