Preview:
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);
};
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter