Preview:
int maxSubArray(vector<int>& nums)
{
    int sum=0;
    int maxi = INT_MIN;
    for(int i=0;i<nums.size();++i)
    {   sum+=nums[i];
        maxi = max(maxi,sum);
        if(sum<0)
        sum=0;
    }
    return maxi;
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter