easy python solution, beats 100% 🔥🔥
Intuition\n Describe your first thoughts on how to solve this problem. \nProperty:\nA binary number is maximum when its \'1\'s occupy more significant positions
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nProperty:\nA binary number is maximum when its \'1\'s occupy more significant positions (left)\n\nInference from rules :\n    "00" can be changed to "10"\n    "10" can be changed to "01" -> allows us to move any number of zeroes towards complete left\n\nso moving all the zeroes to left and converting "00" to "10" will give the maximum number possible\n\nNote:\nleave the 1\'s present in leftmost positions unaltered, as they are already in ideal position\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nstarting from left of binary string, count the leading number of ones , say \'i\', and initialize the result string with \'i\' number of ones\n\ncount the number of zeroes in the string, say \'c\', from the rule - "00" can be converted to "10", c-1 zeroes can be converted to ones, so append (c-1) \'1\' + \'0\' to resultant string\n\nappend the remaining number of ones to resultant string to obtain the final result\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1), (constant)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution(object):\n    def maximumBinaryString(self, binary):\n        i,l = 0,len(binary)\n        while i<l and binary[i]==\'1\':i+=1\n        c = binary.count(\'0\')\n        return \'1\'*i+\'1\'*(c-1)+\'0\'*(1 if c>0 else 0)+\'1\'*(l-i-c)\n\n\n\n            \n            \n        \n        \n```
['Python']