Maximum Subarray (Kadane's Algo) (Leetcode 53)

Problem Link: https://leetcode.com/problems/maximum-subarray/

class Solution:
    def maxSubArray(self, nums: List[int]) -> int:
        meh=float('-inf')
        msf=float('-inf')
        for i in nums:
            meh=meh+i
            if(i>meh):
                meh=i
            if(meh>msf):
                msf=meh
        return msf

Last updated