C++ Easy Solution O(n)
\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n        string ans;\n        bool first_zero=false;\n        int consecutive_ones=
```\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n        string ans;\n        bool first_zero=false;\n        int consecutive_ones=0;\n        for(int i=0;i<binary.size();i++)\n        {\n            if(binary[i]==\'0\' && first_zero==false)\n            {\n                first_zero=true;\n            }\n            else if(binary[i]==\'1\' && first_zero==true)\n            {\n                consecutive_ones++;\n            }\n            else if(binary[i]==\'1\' && first_zero==false)\n            {\n                ans.push_back(binary[i]);\n            }\n            else if(binary[i]==\'0\' && first_zero==true)\n            {\n                ans.push_back(\'1\');\n            }\n        }\n        if(first_zero==true)\n        {\n            ans.push_back(\'0\');\n        }\n        while(consecutive_ones!=0)\n        {\n            ans.push_back(\'1\');\n            consecutive_ones--;\n        }\n        for(int i=1;i<ans.size();i++)\n        {\n            if(ans[i]==\'0\' && ans[i-1]==\'0\')\n            {\n                ans[i-1]=\'1\';\n            }\n        }\n        return ans;\n    }\n};\n```
[]