Longest Increasing Subsequence

Medium

Return the length of the longest strictly increasing subsequence of nums (elements keep their relative order but need not be adjacent).

Example 1

lengthOfLIS()
Input
nums = [10,9,2,5,3,7,101,18]
Output
4

Why

[2,3,7,101]

Example 2

lengthOfLIS()
Input
nums = [0,1,0,3,2,3]
Output
4
Constraints
1 <= nums.length <= 2500
-10^4 <= nums[i] <= 10^4

Topics

Dynamic ProgrammingBinary SearchArrays

Implement lengthOfLIS in the editor and return the answer — printing it is never graded.