What's the problem of my code?


  • 0
    X
    class Solution:
        # @param {integer[]} nums
        # @return {integer}
           
        def maxSubArray(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            self.helper(nums,0,len(nums))        
            
        def helper(self,nums,left,right):
            if left > right:return -(1<<32)
            m = (left + right)/2
            leftMax = sums = 0
            for i in range(left,m):
                sums+= nums[i]
                leftMax = max(leftMax,sums)
            
            rightMax = sums = 0
            for i in range(m+1,right):
                sums += nums[i]
                rightMax = max(rightMax,sums)
                
            lm = self.helper(nums,left,m)
            rm = self.helper(nums,m+1,right)
            return max(lm,rm,lm+nums[m]+rm)

Log in to reply
 

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