1、力扣原题
https://leetcode-cn.com/problems/maximum-subarray/
- 思路:动态规划
class Solution {
public int maxSubArray(int[] nums) {
int count = nums.length;
int[] resultArray = new int[count];
resultArray[0] = nums[0];
int maxValue = resultArray[0];
for (int i = 1; i < count; i++) {
resultArray[i] = Math.max(resultArray[i - 1] + nums[i],nums[i]);
maxValue = Math.max(resultArray[i],maxValue);
}
return maxValue;
}
}