Solution to Greatest Sum Of Subarrays from Jobdu

28 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1372

Question Name: Greatest Sum Of Subarrays

Question Description: Given an integer array, find the non-empty subarray with the greatest sum. If there are multiple subarray with the same greatest sum, return the one with the smallest begin index. If there are multiple subarray with the same greatest sum and begin index, return the one with the smallest end index.

Input: the input might contain multiple test cases. Each test case contains two lines. The first line includes one integers N (1 <= K <= N <= 100000). The second line includes N integers as the input array.

Output: For each test case, print one line with three integers: the sum, the begin index, and the end index.

The solution is:

2 Replies to “Solution to Greatest Sum Of Subarrays from Jobdu

    • First of all, thanks for sharing your solutions!
      In the next time, could you please add the language name, remove the duplicate problem description, and add some essential comments?

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!