keep left and right pointer.
increment left till you encounter 1 as you move along left pointer.(left to right)
Similarly decrement right till you encounter 0 as you move along right pointer.(right to left)
if left < right
swap the elements
and continue from the top if left pointer < right pointer
[gist https://gist.github.com/vishnujayvel/ad165150acce269c4690 ]
Continue reading