Solution in C++ ( Greedy + Observation )
Let\'s take an example\n11101010 -> 11100110 -> 11100101 -> 11100011\n-> 11110011 -> 11111011\n11111011 = output.\n\nFollowing observations seen after taking so
Let\'s take an example\n11101010 -> 11100110 -> 11100101 -> 11100011\n-> 11110011 -> 11111011\n11111011 = output.\n\nFollowing observations seen after taking some inputs :-\n1. There will be only one 0 in resultant string\n2. Other\'s will be 1\'s in resultant string\n3. 00 -> 10\n4. 10 -> 01\n\nAlgorithm -\n1. Count zeros in string(c).\n2. Make a resultant string of same size as given string with all 1\'s\n3. Mark (c-1 index + first 0th index ) as 0\n\n\n   ```\n string maximumBinaryString(string s) {\n        int i,j,n=s.size();\n        int c=0;\n        string ans(n,\'1\');\n        for(char x:s){\n            if(x==\'0\') c++;\n        }\n        \n        for(i=0;i<n;i++)\n        {\n            if(s[i]==\'0\')\n            {\n                ans[i+c-1]=\'0\';\n                break;\n            }\n        }\n        \n        return ans;\n\t\t}\n```
['String', 'Greedy', 'C']