DSA · Reimagined
Recursion & DP medium time O(n²) space O(n)

DP — Longest Increasing Subsequence

dp[i] is the length of the longest increasing subsequence that ends at index i. To fill it, look back at every earlier element that is smaller and take the best chain you could extend. The answer is the largest entry.

array
3
0
1
1
8
2
2
3
5
4
6
5
dp[i] = longest chain ending at i
1
0
1
1
1
2
1
3
1
4
1
5

Every element is a chain of length 1 on its own.

1 / 22
A fixed scene — scrub through it, or open the code.

Practice

Machine twin: /dsa-viz-v2/lis.json — the full deterministic run as structured data.