0,0
Current Cell
-
Characters
0
LCS Length
-
Recovered LCS
Ready
Status
Current DP cell
Character match (diagonal + 1)
Take max from top/left
Backtracked LCS path
Step Log
How It Works
The Longest Common Subsequence DP table stores dp[i][j]: the LCS length between prefixes A[0..i-1] and B[0..j-1].
- If the two characters match, take the diagonal value plus one.
- Otherwise, carry forward the better value from the top or left cell.
- After filling the table, backtracking reconstructs one actual LCS string.