Return the length of the longest strictly increasing subsequence of nums.
tails[k] = the smallest possible tail of an increasing subsequence of length k+1. For each x, binary-search the first tail ≥ x and replace it, or append x if none exists.
1function lengthOfLIS(nums: number[]): number {2const tails: number[] = [];3for (const x of nums) {4let lo = 0, hi = tails.length;5while (lo < hi) {6const mid = (lo + hi) >> 1;7if (tails[mid] < x) lo = mid + 1;8else hi = mid;9}10tails[lo] = x;11}12return tails.length;13}
tails is empty.
Space: play/pause · ←/→: step