index | submit | rank | book

max-subarray – Maximum subarray

Write a program that solves the maximum subarray problem. In a given array or list, your program must find the maximum sum of a contiguous selection of elements.

The maximum subarray problem

Input and Output

Each line of input will contain several integers separated by space. There will be no more than 1000 integers per line and their absolute value shall not exceed 999.

Example input

-1 0 9 -8
1 -2 3 4 -5 6 -7
-14 32 -30 60 -360

Example output

9
8
62

Scoring

try first: cash

try next: sorting

index | submit | rank | book

Copyright © 2020-2021 Rudy Matela
All rights reserved