Module 10 · Dynamic Programming · DP: Inclusion–Exclusion

Longest increasing subsequence

dp[i] is the longest increasing subsequence that ends at nums[i]: one on its own, or one more than the best dp[j] of an earlier, smaller number it can follow. The answer is the largest dp[i].

dp[i] is the length of the longest increasing subsequence ending at nums[i]; subsequence shows that subsequence.