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
Use 2D DP where each state compares prefixes. If current chars match, carry diagonal value; otherwise take min of insert/delete/replace transitions plus one.
Optimal edit sequence has optimal substructure over smaller prefix pairs, which DP enumerates exhaustively.
Updated Feb 2026