Longest rising subsequence
Return the length of the longest subsequence of nums whose values strictly rise from left to right. A subsequence keeps the values in their original order but may skip any of them: [1, 4, 5] is one of [3, 1, 4, 1, 5].
nums has 0 to 10,000 integers between −10⁹ and 10⁹, possibly repeated. Aim for O(n log n) time.
Besides the tests, one large input (5,000 values) with a ~200 ms limit (scaled to your device's speed): brute force won't pass.
Examples
longest_rising([3,1,4,1,5,9,2,6])→4longest_rising([8,8,8,8])→1longest_rising([6,2,7,3,4])→3