dsa · medium

Longest Increasing Subsequence

Return the length of the longest **strictly increasing** subsequence of nums. A subsequence keeps relative order but need not be contiguous.

Arguments

Example

[10,9,2,5,3,7,101,18]4 (for example 2,3,7,18).

[0,1,0,3,2,3]4.

[7,7,7,7]1.

Constraints

1 <= nums.length <= 2500 -10^4 <= nums[i] <= 10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[10,9,2,5,3,7,101,18]

Expected:
4

Example 2

Input:
[0,1,0,3,2,3]

Expected:
4

Example 3

Input:
[7,7,7,7]

Expected:
1

Open in the Dojo editor