My c# solution which is accepted


  • 0
    Y

    if (nums.Length == 0)
    return 0;
    int maxValue = nums[0];
    int curr = 0;
    for(int i=0;i<nums.Length;i++)
    {
    curr += nums[i];

                if (maxValue < curr)
                    maxValue = curr;
                
                if (curr < 0)
                        curr = 0;
            }
            return maxValue;

Log in to reply
 

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