Longest Increasing Subsequence
MediumLeetCode1-D Dynamic Programming
Approach hintTry it first, then revealHide
The O(n^2) DP sets dp[i] to one plus the best dp[j] over earlier, smaller values. For O(n log n), keep the smallest possible tail for each subsequence length and update it with binary search.