C++ greedy approach
\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n        // goal: add all already most left 1\'s to ans\n        // push any 1\'s p
```\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n        // goal: add all already most left 1\'s to ans\n        // push any 1\'s past that to the most right\n        // if there is only 1 zero it should stay the same\n        // fill out all the empty 0 space with 1s except the most right  0 space\n        int i = 0;\n        string ans = "";\n        while (i < binary.size() && binary[i] == \'1\')\n            ans += binary[i++];\n        // count the number of 1s and 0s left\n        int oneC = 0, zeroC = 0;\n        while (i < binary.size()){\n            oneC += binary[i] == \'1\';\n            zeroC += binary[i++] == \'0\';\n        }\n        for (i = 0; i < zeroC - 1; ++i) ans += \'1\';\n        if (zeroC > 0) ans += \'0\';\n        for (i = 0; i < oneC; ++i) ans += \'1\';\n        return ans;   \n    }\n};\n```
[]