Coding test/programmers - single

[leetcode] 53. Maximum Subarray

engine 2022. 3. 26. 16:25
class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        bstsum = -sys.maxsize
        crsum = 0
        
        for num in nums :
            crsum = max(num, num + crsum)
            bstsum = max(crsum, bstsum)
        return bstsum