Longest Increasing Subsequence
Given an array of integers, find the length of the longest subsequence whose elements appear in strictly increasing order. A subsequence keeps the relative order of the array but does not have to be contiguous.
nums = [50, 3, 10, 7, 40, 80]
4
[3, 7, 40, 80] increases at every step and uses four elements. [3, 10, 40, 80] is another subsequence of the same length, so the answer is the length rather than the subsequence itself.
nums = [1, 2, 4, 3]
3
Both [1, 2, 4] and [1, 2, 3] are longest increasing subsequences which have length 3.
nums = [10, 9, 2, 5, 3, 7, 101, 18]
4
[2, 3, 7, 101] and [2, 5, 7, 18] both reach length 4. Nothing longer exists because the leading 10, 9 cannot extend any of them.
0 <= nums.length <= 2500-10^4 <= nums[i] <= 10^4