title: Flip the bits in C
body: <p>Recently in a interview i was asked the below question and i couldn't able to answer it correctly. Can some one please let me know what exactly the answer is.<br>
  Question:
  You are given an array of size N. The elements of the array are d[0],d[1]...d[N-1] where each d[i] is either 0 or 1. You can perform at most one move on the array :choose any two integers [L,R] and flip all the elements between (and including) the Lth and Rth bits. L and R represent the left most and the right most index of the bits marking the boundaries of the segment which you have decided to flip.</p>
  
  <p>What is the maximum number if 1 - bits (indicated by S) which you can obtain in the final bit string? 'Flipping ' a bit means , that a 0 is transformed to a 1 and a 1 is transformed to a 0.</p>
  
  <p>sample input
  8
  10010010</p>
  
  <p>sample output
  6</p>