title: Find the longest subsequence containing as many 1 as 0 time O(n)
body: <p>I had a question in an interview and I couldn't find the optimal solution (and it's quite frustrating lol)</p>
  
  <p>So you have a n-list of 1 and 0.
  110000110101110..
  The goal is to extract the longest sub sequence containing as many 1 as 0.
  Here for example it is "110000110101" or "100001101011" or "0000110101110"</p>
  
  <p>I have an idea for O(n^2), just scanning all possibilities from the beginning to the end, but apparently there is a way to do it in O(n).
  Any ideas?</p>
  
  <p>Thanks a lot!</p>