Python solution, >98%


  • 0
    S
    def maxSubArray(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            mem = [nums[0]]
            for i in range(1, len(nums)):
                if mem[len(mem)-1] > 0:
                    mem.append(mem[len(mem)-1]+nums[i])
                else:
                    mem.append(nums[i])
            
            return max(mem)

Log in to reply
 

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