Pesky greedy
Rules 00->10->01\n1. It\'s always better to keep prefix of 1s as is. (e.g. 11110 vs 01111, 10 vs 01, 1111)\n2. A few observations from provided below examples  
0. Rules `00`->`10`->`01`\n1. It\'s always better to keep prefix of `1s` as is. (e.g. `11110` vs `01111`, `10` vs `01`, `1111`)\n2. A few observations from provided below examples  (it took a while to figure out all of this :(((((( greedy )\n- sequence of `prefix0101101` with help of (`10` ->`01`) will always end up as `prefix0001111` and then with help of (`00` -> `10`) will become `prefix1101111`. \n- Final sequence will be either all `1` or all `1` + one `0`\n3. Find prefix of `1`\n4. Count number of `1` in suffix\n5. Place `0` at position `~ones_in_suffix` if `prefix+ones_in_suffix != N`\n ```\nclass Solution:\n    def maximumBinaryString(self, s: str) -> str:\n        """\n        00 -> 10 -> 01\n        \n        000110 -> 111011\n       |000011\n        \n        0101 -> 1011\n       |0011\n        \n        1010 -> 1101\n       1|001\n        \n        101010 -> 111011\n       1|00011\n        \n        010101 -> 110111\n       |000111\n       \n       1100 -> 1110\n\t 11|\n       \n        """\n        N = len(s)\n        prefix = suffix = 0\n        for i in range(N):\n            if i == prefix and s[i] == \'1\':\n                prefix += 1\n                continue\n            suffix += s[i] == \'1\'\n        res = [\'1\'] * N\n        if prefix + suffix != N:\n            res[~suffix] = \'0\'\n        return \'\'.join(res)\n```
['Greedy', 'Python', 'Python3']