1
0
0

LeetCode53-最大子数组和

文章摘要
|

不多说了,特别简单

class Solution {
    public int maxSubArray(int[] nums) {
        int a = 0;
        int maxAns = nums[0];
        for(int i : nums){
          a = Math.max(a + i, i);
          maxAns = Math.max(maxAns, a);
        }
        return maxAns;
    }
}

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或者给予支持!

评论