Beautiful Binary String

  • + 0 comments

    Can someone explain how they did this one? I was able to pass all but one test case. My method was:

    1010 -> 1000
    0101 -> 0111
    0100 -> 1100
    0010 -> 0011
    

    And I passed over the array once forward and once in reverse and took the minimum number of swaps of the traversals.