Intuitive: Time Complexity O(n) Simple approach
\n/**\n * @param {string} binary\n * @return {string}\n */\nvar maximumBinaryString = function(binary) {\n    /*\n    10 -> 01 allows us to move any zero to lef
```\n/**\n * @param {string} binary\n * @return {string}\n */\nvar maximumBinaryString = function(binary) {\n    /*\n    10 -> 01 allows us to move any zero to left by one position\n    00 -> 10 allows us to convert any consicutive 00 to 10\n    So we can collect all the zeros together then convert them in 1 except for the rightmost 0\n    We will club all the zeros togegher on the rightmost possition, to achieve the biggest value, then covert them into 1 except for the rightmost 0\n    So we need to choose indexOfFirstZero as the starting possition of the group of zeros\n    If there is no 0 then given string is the maximum possible string\n    If there are 1 or more zeros\n        Then there will be only 1 zero in the answer\n        Position of this will be indexOfFirstZero in given string + countOfZeros - 1\n    */\n    let firstZeroIndex=-1,zeroCount=0,ans="";\n    for(let i=0;i<binary.length;i++){\n        if(binary[i]===\'0\'){\n            zeroCount++;\n            if(firstZeroIndex===-1){\n                firstZeroIndex=i;\n            }\n        }\n    }\n    if(firstZeroIndex==-1){\n        return  binary; \n    }\n    let onlyZeroInAns = firstZeroIndex + (zeroCount-1);\n    for(let i=0;i<binary.length;i++){\n        if(i==onlyZeroInAns){\n            ans+="0";\n        }\n        else{\n            ans+="1";\n        }\n    }\n    return ans;\n};\n```
['JavaScript']