Pick an increasing subsequence of nums: some of its values, in their original order, each strictly larger than the one before it. Elements in between may be skipped. Return the largest number of values you can pick.
Example 1
Input
nums = [3, 1, 4, 1, 5, 9, 2, 6]
Output
4
Explanation
[3, 4, 5, 9] is one choice with 4 values, and no choice has 5.
Example 2
Input
nums = [2, 2, 3, 3, 4]
Output
3
Explanation
[2, 3, 4] works. The repeated 2s and 3s cannot both be used, because equal values do not count as growing.
Example 3
Input
nums = [8, 6, 4, 2]
Output
1
Explanation
every value is smaller than the one before it, so no two can be picked together and a single element is the best you can do.
Constraints:
1 <= nums.length <= 2500
-10^4 <= nums[i] <= 10^4
Tab indents. Press Esc, then Tab to leave the editor.
Ctrl or ⌘ + Enter runs the tests.
Run your code to see every test here. Nothing is submitted or recorded.