easy O(n) sol with comments and explanation 7 lines
class Solution:\n    def maximumBinaryString(self, bi: str) -> str:\n        \n\t\t"""\n\t\tIntution:\n\t\t\twe need to move first \'0\' to as far as possible f
class Solution:\n    def maximumBinaryString(self, bi: str) -> str:\n        \n\t\t"""\n\t\tIntution:\n\t\t\twe need to move first \'0\' to as far as possible from left side to right side to get highest number.\n\t\t\tso by doing \'10\'->\'01\' operation we need to bring right zeros to the left most \'0\'.\n\t\t\tso that they both will form \'00\' that can be converted to \'00\' --> \'10\' so that the left most zero moves to the right\n\t\t\t\n\t\t\tex: "1010110"\n\t\t\t\tthe first zero is at index 1 so move next zero to left one by \'10\'->\'01\' operations\n\t\t\t\t\n\t\t\t\t1010110 --> 1001110 \n\t\t\t\t\n\t\t\t\tnow change \'00\' -> \'10\'\n\t\t\t\t\n\t\t\t\t1001110 --> 1101110\n\t\t\t\t\n\t\t\t\tnow again bring other zero to left\n\t\t\t\t\n\t\t\t\t1001110 --> 1100111\n\t\t\t\t\n\t\t\t\tnow finally conver \'00\' ->\t\'10\'\n\t\t\t\t\n\t\t\t\t1001110 --> 1110111(the biggest possible)\n\t\t"""\n        \n        s = list(bi)#taken that in list so that we can change values\n        n=len(bi)\n        \n        #ind represents index of first 0 and co is count of zeros exept first one\n        ind=-1; co=-1\n        for i in range(n):\n            if ind==-1 and s[i]==\'0\': ind=i\n            \n            if s[i]==\'0\': co+=1\n                \n                \n        \n        for i in range(n):\n            #move first zero to ind+countof zeros-1\n            if i==ind+co: s[i]=\'0\'\n            #replace remaining all with 1\n            else: s[i]=\'1\'\n        #joins again array to string\n        return "".join(s)\n
['Python3']