leetcode-mid-dynamic programming- Longest Increasing Subsequence-NO

will not. . .

reference:

The idea is similar to coin the title, for the cycle to update the information on the current position at the time of the condition

def lengthOfLIS(nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        if nums==[]:
            return 0
        N = len(nums)
        Dp = [1]*N
        print(N,Dp)
        for i in range(N-1):
            for j in range(0,i+1):
                if nums[i+1]>nums[j]:
                    Dp[i+1] = max(Dp[i+1],Dp[j]+1)
        return max(Dp)

 

Guess you like

Origin www.cnblogs.com/rosyYY/p/10981394.html