#300
Longest Increasing Subsequence
medium· 1-D DPruns: 0Given an integer array nums, return the length of the longest strictly increasing subsequence.
sign in to paste and practice your own solution
wpm 0acc 100%time 0:000 / 273
class Solution:
def lengthOfLIS(self, nums: list[int]) -> int:
dp = [1] * len(nums)
for i in range(len(nums)):
for j in range(i):
if nums[j] < nums[i]:
dp[i] = max(dp[i], dp[j] + 1)
return max(dp)
click the box to focus · tab inserts 4 spaces · backspace to correct · esc to pause
desktop only
codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.
you can still browse problems and sections from your phone.