CJCoding With Joseph

Maximum Subarray Sum

The array {-2, 1, -3, 4, -1, 2, 1, -5, 4} is given. Find the largest possible sum of any CONTIGUOUS subarray (a run of one or more adjacent elements) and print it:

6

The best run is 4, -1, 2, 1, which sums to 6. Use Kadane's algorithm: track the best sum ending at the current position.

Expected Output:

6
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.