title: How to return maximum sub array in Kadane's algorithm?
body: <pre><code>public class Kadane {
    double maxSubarray(double[] a) {
      double max_so_far = 0;
      double max_ending_here = 0;
  
      for(int i = 0; i &lt; a.length; i++) {
        max_ending_here = Math.max(0, max_ending_here + a[i]);
        max_so_far = Math.max(max_so_far, max_ending_here);
      }
      return max_so_far;
    }
  }
  </code></pre>
  
  <p>The above code returns the sum of the maximum sub-array.</p>
  
  <p>How would I instead return the sub-array which has the maximum sum?</p>