Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 4x 1x 3x 3x 3x 3x 18x 18x 64x 28x 18x 3x | export default function lengthOfLIS(nums: number[]): number {
if (nums.length === 0)
return 0
const dp: number[] = Array.from({ length: nums.length })
dp[0] = 1
let LIS = 1
for (let i = 1; i < nums.length; i++) {
dp[i] = 1
for (let j = 0; j < i; j++) {
if (nums[i] > nums[j])
dp[i] = Math.max(dp[i], dp[j] + 1)
}
LIS = Math.max(LIS, dp[i])
}
return LIS
}
|