Maximum Subarray Sum
hardQuestion 400The 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 (see Expected Output).
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= newline. The output ends with a newline, so print one after the last line.
Hints4 available
Sign in to use hintsTopics
Arrays
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · 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.