A complete platform designed to help you prepare for technical interviews at top companies
Our modern code editor comes with syntax highlighting, auto-completion, and a distraction-free interface. Focus on what matters - solving problems.
function maxSubArray(nums) {
let maxSum = nums[0];
let currentSum = nums[0];
for (let i = 1; i < nums.length; i++) {
currentSum = Math.max(nums[i],
currentSum + nums[i]);
maxSum = Math.max(maxSum, currentSum);
}
return maxSum;
}