Maximum sum in sequence
MEDIUMGiven a string of integers separated by a single space.
Find a sequence of numbers in which the sum of the elements is maximum.
For example, for string "2, -5, 1, 2, -2, 2" solution is the sequence "1 2" with sum = 3.
Print max sum only.
Example #1
Input
-8 -3 -6 -2 -5 -4
Output
-2
Example #2
Input
-2 1 -3 4 -1 2 1 -5 4
Output
6