title: minimum sum subarray in O(N) by Kadane's algorithm
body: <p>We all know about the maximum sum subarray and the famous <a href="http://en.wikipedia.org/wiki/Maximum_subarray_problem#Kadane.27s_algorithm" rel="nofollow noreferrer">Kadane's algorithm</a>. But can we use the same algorithm to find minimum sum also?</p>
  
  <p>My take is: </p>
  
  <blockquote>
    <p><strong>change the sign and find the max sum in that, same as the way we calculate the maximum sum subarray. Than change the sign of the
    elements in the array to make it in initial state.</strong></p>
  </blockquote>
  
  <p>Please help me in correcting the algo if it has any issue. </p>
  
  <p><strong>corner case:</strong> I know there is an issue if all the elements are positive and we can handle this case by doing some preprocessing i.e. traverse the array if all are +ve than just return the minimum number from the array. </p>
  
  <p><strong><em>The above mention algorithm will work and well supported (explained) by <a href="https://stackoverflow.com/questions/18472606/minimum-sum-subarray-in-on-by-kadanes-algorithm/18472835?noredirect=1#18472835">dasblinkenlight</a>.</em></strong></p>