53. Maximum Subarray
/**
* @param {number[]} nums
* @return {number}
*/
var maxSubArray = function(nums) {
let ans = Number.NEGATIVE_INFINITY;
let lastMax = 0
for(const num of nums){
lastMax = Math.max(num, lastMax + num)
ans = Math.max(ans, lastMax)
}
return ans
};