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
O(m·n) time · O(m·n) spaceDP Table: Longest Common Subsequence
Fill a 2-D table cell by cell from smaller subproblems, then walk back to read the answer.
| ∅ | B | D | C | A | B | A | |
|---|---|---|---|---|---|---|---|
| ∅ | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| A | 0 | ||||||
| B | 0 | ||||||
| C | 0 | ||||||
| B | 0 | ||||||
| D | 0 | ||||||
| A | 0 | ||||||
| B | 0 |
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