pumpkin subarray
unknown
java
3 years ago
347 B
5
Indexable
public int maxSubArray(int[] nums) { int curSum = 0; int maxSum = nums[0]; for (int i =0 ; i<nums.length; i++) { curSum = curSum + nums[i]; if(curSum > maxSum) maxSum = curSum; if(curSum < 0) curSum = 0; } return maxSum; }
Editor is loading...