Python -> Managed to get a bigger number than expected answer.
With the following solution, i\'m getting this test case wrong:\n\n\n\nThe logic is: \n1. Perform all "00" substitutions\n2. Find the "10" cases and, if there i
With the following solution, i\'m getting this test case wrong:\n\n![image](https://assets.leetcode.com/users/images/c821f6b5-04e8-4de5-b8d2-1fc71b012bad_1613938420.4560242.png)\n\nThe logic is: \n1. Perform all "00" substitutions\n2. Find the "10" cases and, if there is another 0 to the left of it, make it "01"\n3. Run the whole thing again until there\'s only one 0 left.\n\nHowever, I just applied my logic by hand, step by step, and could get my answer (which means it is possible). Any ideas on what could be wrong with it?\n\nIt is not optimized but should be working\n\n\n```\nclass Solution(object):\n    def maximumBinaryString(self, binary):\n        """\n        :type binary: str\n        :rtype: str\n        """\n        list = []\n        \n        for i in binary:\n            list.append(int(i))\n\n        #Procura 00s e troca\n        flag = 0\n        while flag == 0:\n            for i in range(len(binary)-1):\n                if list[i] == 0 and list[i+1] == 0:\n                    list[i] = 1\n\n\n                    \n            flag = 1\n                \n            for i in range(len(binary)-1,-1,-1):\n                if list[i] == 0 and list [i-1] == 1 and sum(list[0:i-1])<i-1:\n                    list[i] =1\n                    list[i-1] = 0\n                    flag = 0\n        string = \'\'\n        for a in list:\n            string += str(a)\n                \n        return string\n        \n```
[]