Accepted as best in C


  • 3
    int maxSubArray(int* nums, int size)
    {
        int sum = 0;
        int max = INT_MIN;
        for(int i = 0; i < size; i++)
        {
            if(sum >= 0)
                sum += nums[i];
            else
                sum = nums[i];
            if(sum > max)
                max = sum;
        }
        return max;
    }

Log in to reply
 

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