Sun Oct 06 2024 23:38:03 GMT+0000 (Coordinated Universal Time)
Saved by @kanatov
function lengthOfLIS(nums: number[]): number { const dp = new Array(nums.length).fill(1); for (let i = 1; i < nums.length; i++) { for (let j = 0; j < i; j++) { if(nums[j] < nums[i]) { dp[i] = Math.max(dp[i],dp[j]+1,); } } } return Math.max(...dp); };
Copy this HTML code:
Preview:
open_in_newInstructions on embedding in Medium
Comments