Last updated 1 year ago
var maxSubArray = function(nums) { let maxSum = -Infinity; let currSum = 0; for (let i = 0; i < nums.length; i++) { const curr = nums[i]; currSum = Math.max(curr, currSum + curr); maxSum = Math.max(maxSum, currSum); } return maxSum; };