Maximum Subarray


Submit solution


Points: 7 (partial)
Time limit: 1.0s
Python 2.0s
Memory limit: 256M

Author:
Problem type

Given an array of integers \(nums\), find the subarray with the largest sum and return that sum.

Constraints

\(1 \le nums.length \le 10^5\)
\(-10^4 \le nums[i] \le 10^4\)

Input Specification

The first line of input will have one integer \(N\), the length of nums The next \(N\) lines will contain a value in the nums array

Output Specification

Output a single integer representing the sum of the values in the subarray with the largest sum.

Sample Input 1

5
5
4
-1
7
8

Sample Output 1

23

Comments

There are no comments at the moment.