O(n) javascript solution
the goal is to find the index of the final \'0\'.\nif we have 0111...1110 it will be 10111...111 (because 10->01 so we try to make the two zeros as close as pos
the goal is to find the index of the final \'0\'.\nif we have 0111...1110 it will be 10111...111 (because 10->01 so we try to make the two zeros as close as possible in order to replace 00 with10 which is maximizing the binary) so each time we find two zeros ch+="1" and save the index of the first zero +1.\nguys if you understand my explanation and you can explain it better please feel free to add more detailed explanation in the comment section below and hf everyone.\n```\nvar maximumBinaryString = function(binary) {\nlet ch = "",start;\nfor (let i = 0; i < binary.length; i++) {\n    if (binary[i]=="0") {\n        if (start==undefined) start=i;\n        else {\n\t\t   // the second zero is with index i and the first zero is with index start\n            ch+="1"; \n            start+=1;\n        }\n    }\n    else if(start==undefined) ch+="1"; // case : we start with ones\n}\nif(start==0 || start==undefined) return binary; // case : (/01+/) or (/1+/)\nreturn ch+"0"+"1".repeat(binary.length-start-1);\n};\n```
['JavaScript']