标签:
Iteration:
public class Solution { public int maxSubArray(int[] nums) { int start = 0, end = nums.length-1; //return sumSubArray(nums, 0, Integer.MIN_VALUE, start, end); int max = Integer.MIN_VALUE; int sum = 0; while(start <= end){ sum += nums[start]; if(sum <= 0){ max = sum > max? sum:max; start++; sum = 0; } else{ max = sum > max? sum:max; start++; } } return max; } }
Jan 18 - Maximum Subarray; DAC; DP; Array;
标签:
原文地址:http://www.cnblogs.com/5683yue/p/5141006.html