Open pwstrick opened 4 years ago
53. 最大子序和
/** * @param {number[]} nums * @return {number} */ var maxSubArray = function(nums) { const len = nums.length; let max = Math.max.apply(undefined, nums); let sum; for(let i=0; i<len; i++) { sum = nums[i]; for(let j=i+1; j<len; j++) { sum += nums[j]; max = Math.max.call(undefined, sum, max); } } return max; };
53. 最大子序和