Find the length of the longest strictly increasing subsequence in an array.
LIS
gfgIncreasing Subsequence
gfgGiven an integer array nums, determine the length of the longest subsequence whose values are strictly increasing.
A subsequence is formed by deleting zero or more elements without changing the order of the remaining elements. The elements do not need to be contiguous.
Your task is to return only the maximum length of such a subsequence.
nums.nums.1 <= nums.length <= 2500$-10^{4}$ <= nums[i] <= $10^{4}$1 when the array is non-empty.Example 1
Input
nums = [10,9,2,5,3,7,101,18]
Output
4
Explanation
One longest increasing subsequence is [2,3,7,101], which has length 4.
Example 2
Input
nums = [0,1,0,3,2,3]
Output
4
Explanation
One longest increasing subsequence is [0,1,2,3].
Example 3
Input
nums = [7,7,7,7,7]
Output
1
Explanation
Any single element is an increasing subsequence, but no longer strictly increasing subsequence exists.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.