title: What is the procedure for Minimum contiguous sum with atmost K swaps
body: <p>I have an array say <code>{-1,2,3,4,-3,-2,1,5}</code></p>
  
  <p>Now I would like to find the minimum contiguous sum subarray for the given array with atmost <code>K</code> swaps.</p>
  
  <p>In the array above the minimum contiguous sum is <code>-5</code> and subarray is <code>{-3,-2}</code></p>
  
  <p>Say for <code>K=1</code> How should I swap the elements</p>
  
  <ol>
  <li><p>Should I swap the left element of the sub array i,e; swaping element <code>4</code> at <code>a[3]</code>  which is left to it with <code>-1</code> (again with which number (sub question pops up in my mind)?</p>
  
  <p>a. whether the lowest of the the remaining elements (with any sorting technique of the remaining elements excluding subarrays). If I do this  I will swap <code>-1</code> with <code>4</code> and the min sum will be <code>{-1,-3,-2}</code>
  As per "<strong><em>atmost</em></strong>" <code>K</code> swaps I can return this the subarray with only one swap even how long the array is</p></li>
  <li><p>Should I swap the element <code>1</code> at the postion <code>a[6]</code> with <code>-1</code> and get the sub array with min sum as <code>{-3,-2,-1}</code>. Again following the same question at point a above.</p></li>
  </ol>
  
  <p>This whole process I would like to do with recursion. As I am dealing with arrays with <code>N</code> integers. Which is best approach I should follow recursion or iteration?</p>