标签:
public 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(global, local); } return global; } }
全局最优 局部最优
标签:
原文地址:http://www.cnblogs.com/77rousongpai/p/4521578.html