Skip to main content
HS
HiSETSuccess
LeetCode Prep

Algorithm Visualizer

Step through two pointers, sliding window, binary search, BFS/DFS, heaps, DP, and union-find one operation at a time.

← All visualizers

DP Table: Longest Common Subsequence

Fill a 2-D table cell by cell from smaller subproblems, then walk back to read the answer.

O(m·n) time · O(m·n) space

Two words of up to 8 letters, separated by a comma.

Presets
∅BDCABA
∅0000000
A0
B0
C0
B0
D0
A0
B0

1/44dp[i][j] = length of the longest common subsequence of the first i letters of "ABCBDAB" and the first j letters of "BDCABA". Empty prefixes score 0.

Keyboard: ← → step · Space play/pause