class Solution {
    public int maxSubArray(int[] nums) {
        if(nums == null || nums.length == 0){
            return 0;
        }
        int local = nums[0];
        int global = nums[0];
        for(int i=1; i<nums.length; i++){
            local = Math.max(nums[i], local+nums[i]);
            global = Math.max(local, global);
        }
        return global;
    }
}

分治思想:https://blog.csdn.net/fengpojian/article/details/82788752

53. 最大子序和

相关文章:

  • 2021-11-16
  • 2021-10-18
  • 2021-06-19
  • 2021-08-09
  • 2021-12-04
  • 2021-07-28
  • 2021-08-22
  • 2021-06-17
猜你喜欢
  • 2021-08-07
  • 2021-04-14
相关资源
相似解决方案