Easy to understand Python

  • 0
    class Solution(object):
        def lengthOfLIS(self, nums):
            :type nums: List[int]
            :rtype: int
            maxVal = 0
            count = [1]*len(nums)
            for i in range( len(nums) ):
            	for j in range(0,i):
            		if nums[j]<nums[i]:
            			count[i] = max( count[i], count[j]+1 )
            	maxVal = max( count[i], maxVal )
            return maxVal

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.