title: Algorithm for minimum sum subvector
body: <p>The problem found in programming pearls column 8 is as follows:</p>
  
  <p><strong>Given the real vector x[n], compute the maximum sum found in any contiguous subvector.</strong></p>
  
  <p>The final solution provided is of O(n) complexity which is as follows:</p>
  
  <pre><code>std::vector&lt;int&gt; x;
  int max_so_far = 0;
  int max_here = 0;
  for (std::size_t i = 0; i &lt; x.size(); ++i)
  {
     max_here = std::max(max_here + x[i], 0);
     max_so_far = std::max(max_so_far, max_here);
  }
  </code></pre>
  
  <p>I would like to know how does one go about modifing the above algorithm to provide the <em>minimum sum</em>.</p>