01 · Question
Given an integer array nums, return the length of the longest strictly increasing subsequence.
02 · Analysis
The main solution defines dp[i] as the longest strictly increasing subsequence ending at i, then extends every earlier smaller value. The best can end anywhere, so return max(dp), or 0 for empty input. Time O(n^2), space O(n). The alternative keeps the smallest possible tail for each length: replace the first tail >= x, or append if none exists. Smaller tails preserve at least as many future extensions; duplicates replace rather than lengthen. Binary search yields O(n log(n+1)) time and O(n) space. Tails themselves need not form one actual subsequence.
03 · Solution