4ms C DP solution


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

    }


  • 0

    Thank you for your solution-sharing.


Log in to reply
 

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