Joey LIU | NANTSOU


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
class Solution {
    public int maxSubArray(int[] nums) {
        int local = nums[0], res = nums[0];
        for (int i = 1; i < nums.length; i++) {
            local = Math.max(nums[i], local + nums[i]);
            res = Math.max(res, local);
        }
        return res;
    }
}