Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Example 1
Input: nums = [10,9,2,5,3,7,101,18] Output: 4
Example 2
Input: nums = [0,1,0,3,2,3] Output: 4
Show hint
Use DP: dp[i] = length of LIS ending at index i. For each i, check all previous j where nums[j] < nums[i] and update dp[i] = max(dp[i], dp[j] + 1).
Sign in to submit, save progress and mark problems as solved. You can still run your code.
Loading editor...
nums =
[10,9,2,5,3,7,101,18]
Expected
4