Level
LeetCode Easy
Recruitment
var maxSubArray = function (nums) {
  let max = -Infinity;

  for (let i = 0; i < nums.length; i++) {
    let subSum = 0;
    for (let j = i; j < nums.length; j++) {
      subSum += nums[j];
      if (subSum > max) max = subSum;
    }
  }

  return max;
};