JS (JavaScript) fast simple solution. O(n)
\n# Code\n\n/**\n * @param {string} binary\n * @return {string}\n */\nvar maximumBinaryString = function(binary) {\n    let firstZero = 0\n    let zeroCounter =
\n# Code\n```\n/**\n * @param {string} binary\n * @return {string}\n */\nvar maximumBinaryString = function(binary) {\n    let firstZero = 0\n    let zeroCounter = 0\n    for (let i = binary.length - 1; i >= 0; i--){\n        if (binary[i] === "0"){\n            zeroCounter++\n            firstZero = i\n        }\n    }\n    if (zeroCounter === 0) return binary\n    let firstPath = firstZero + zeroCounter - 1\n    if (firstPath <= 0) return "0" + "1".repeat(binary.length - 1)\n    else return "1".repeat(firstPath) + "0" + "1".repeat(binary.length - 1 - firstPath)\n};\n```
['JavaScript']