|| Fundamental Approach || C++ || Math Trick || Paper & Pen ||
Code\n\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n// The solution is not very intuitive, it needs a mathamatical analysis. The
# Code\n```\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n// The solution is not very intuitive, it needs a mathamatical analysis. The main point is, if we try to maximize any binary string using the given transformations it leads a string with single zero and the position happens to be same as the position as the last occurence of 0 in the given binary string.\n        int n = binary.size();\n        string output(n, \'1\');\n        int count = 0;\n        for(auto ch:binary) {\n            if(ch == \'0\')\n                count++;\n        }\n        for(int i=0;i<n;i++) {\n            if(binary[i] == \'0\') {\n                output[i+count-1] = \'0\';\n                return output;\n            }\n        }\n        return output;\n    }\n};\n// Please consider upvoting! Thanks for the support :)\n```
['C++']