C++(Maximum Subarray) by yangchaojie


  • 0
    Y

    class Solution {
    public:
    int maxSubArray(vector<int>& nums) {
    int res = INT_MIN, curSum = 0;
    for (int num : nums) {
    curSum = max(curSum + num, num);
    res = max(res, curSum);
    }
    return res;
    }
    };


Log in to reply
 

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