LCS Visualizer            

DP Table Visualization

Progress: 0 / 00%
AEBDF
Speed:
500ms

Current Step Explanation:

Legend:

Current cell
Comparing cells
Character match
Traceback path

Pseudo Code:

function LCS(string A, string B):
if A[i-1] == B[j-1]:
dp[i][j] = dp[i-1][j-1] + 1
else:
dp[i][j] = max(dp[i-1][j], dp[i][j-1])
// After filling table, traceback to find LCS

Algorithm Overview

The Longest Common Subsequence (LCS) problem finds the longest subsequence common to two sequences. Unlike substrings, subsequences don't need to be consecutive elements.

For example, the LCS of "ABCDEF" and "AEBDF" is "ABDF" with length 4.

Legend:

Current cell
Comparing cells
Character match
Traceback path