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
Initialize prefix with the first string, then keep shrinking it until each remaining string starts with that prefix.
The common prefix cannot be longer than the shortest mismatch point, so repeated shrinking converges to the maximal shared prefix.
Updated Feb 2026