python3 with explanation
Two general steps to get the maximum binary string.\n1. Keep using \'10\' --> \'01\' to move 0 forward. We will end up with a string like "1111000......000111",
Two general steps to get the maximum binary string.\n1. Keep using **\'10\' --> \'01\'** to move 0 forward. We will end up with a string like "1111000......000111", when all the \'0\' cannot be moved forward anymore.\n2. Keep using **\'00\' --> \'10\'** to generate \'1\'* (n-1) sequence from the \'0\'* n sequence, until there exist no \'00\' sequence (only one \'0\' left).\n\nFor example:\n110011100---step1--->110000111---step2--->111110111\n\n\nTherefore we need to record two numbers: the number of \'1\' before the first \'0\' appears, these \'1\' will stay unchanged;  The total number of \'0\', since all of the \'0\' will be moved to the middle of the string after the step1 above, and n-1 of them will changed to 1 after step2, only 1 \'0\' will remain.\n\n\n\n```\ndef maximumBinaryString(self, binary: str) -> str:\n        cnt=binary.count(\'0\')\n\t\t#if there exists less than 2 \'0\' in the string, meaning the string has already reached maximum, just return string itself.\n        if cnt>1:\n\t\t\t#i stands for the number of \'1\' before the first \'0\'.\n            i=binary.index(\'0\')\n            # The final string consists of i + (cnt-1) leading \'1\'s, followed by a single \'0\' and the rest \'1\'.\n\t\t\treturn \'1\'*(i+cnt-1)+\'0\'+\'1\'*(len(binary)-i-cnt)\n        else:\n            return binary\n```
[]