classSolution(object):deflengthOfLIS(self, nums):"""
:type nums: List[int]
:rtype: int
"""
dp =[1]*len(nums)
result =1for i inrange(1,len(nums)):for j inrange(i):if nums[i]>nums[j]:
dp[i]=max(dp[i], dp[j]+1)
result =max(dp[i], result)return result
classSolution(object):deffindLengthOfLCIS(self, nums):"""
:type nums: List[int]
:rtype: int
"""
dp =[1]*len(nums)
result =1for i inrange(1,len(nums)):if nums[i]>nums[i-1]:
dp[i]=dp[i-1]+1
result =max(dp[i], result)return result
classSolution(object):deffindLength(self, nums1, nums2):"""
:type nums1: List[int]
:type nums2: List[int]
:rtype: int
"""
dp =[[0]*(len(nums2)+1)for k inrange(len(nums1)+1)]
result =0for i inrange(1,len(nums1)+1):for j inrange(1,len(nums2)+1):if nums1[i-1]==nums2[j-1]:
dp[i][j]=dp[i-1][j-1]+1
result =max(dp[i][j], result)return result