Only Observation || Simplest C++ Sol || O(n) time || O(1) space
Intuiton:\nwe can convert "00" to "10" and "10" to "01".\nWe will use "10" to "01" so that "0" gets shifted to left side so that this "0" combines with other "0
**Intuiton:**\nwe can convert "00" to "10" and "10" to "01".\nWe will use "10" to "01" so that "0" gets shifted to left side so that this "0" combines with other "0" to form "00" to "11";\nOne thing for sure we can always take all the zeroes to the front of string for e.g.\n"01111011" to  "00111111".\nmeans we can take all zeroes to the left side and all ones to the right side. Only edge case is that we should not touch the leftmost 1\'s if present because shifting leftmost 1\'s to right is not leading to optimal answer. for e.g. ""100110011" is converted to "100001111" so that our answer becomes \n"100001111" to "111101111";\n\nLet zero=count of 0\'s in string and one=count of 1\'s in string.\nSo our answer string will be\nanswer=number of leftmost 1\'s + (number of zeroes-1)times 1\'s + 0 +(number of ones) times 1;\nplease note that in above formula of answer single 0 is the 0left after converting all 0\'s to 1.for e,g. "0000" converted to "1110";\n**Try above intuition on pen and paper definitely you will get the logic.**\nPlease comment your doubts if any;\nPlease Upvote  if it helps;)\n```\nclass Solution {\npublic:\n    string maximumBinaryString(string s) {\n        int n=s.size();\n        int ones=0,zeros=0;\n        for(int i=0;i<n;i++)\n        {\n            if(s[i]==\'0\') zeros++;\n            else ones++;\n        }\n        if(zeros==0 || zeros==1) return s; // if no zero or a single zero is in string then our present string is optimal so return s;\n        string ans="";\n        //using formula answer=number of leftmost 1\'s + (number of zeroes-1)times 1\'s + 0 +(number of ones) times 1;\n        for(int i=0;i<n;i++)\n        {\n            if(s[i]==\'1\') ans+=\'1\',ones--;\n            else break;\n        }\n        for(int i=0;i<zeros-1;i++)\n            ans+=\'1\';\n        ans+=\'0\';\n        for(int i=0;i<ones;i++) ans+=\'1\';\n        return ans;\n    }\n};\n```
[]