7. Largest Subarray

Difficulty: 

Given an array of integers, find what the highest sum of numbers in a non-empty contiguous subarray is. For example, [-1, -2, -3] has [-1] which sums up to -1, and [1, -10, 2, 4, -5, 5] has [2, 4] that amounts to 6.

Input:

maxSubarray([
  1,
  -10,
  2,
  4,
  -5,
  5
]);

Output:

6

Time Limit:

500 (ms)

Hints (hover to see):

  • Hint #1
  • Hint #2



Results

ProblemsAcceptedWrongTimed OutError
180000

Input:

Expected Output:

Output: