C++ solution | explained and comments added at each step | O(n) time | O(1) space
There can be a single \'0\' in the answer\nCount the number of zeros to the right of the left most zero -\'zs\'\nMake all the elements of the string as \'1\'\nI
There can be a single \'0\' in the answer\nCount the number of zeros to the right of the left most zero -\'zs\'\nMake all the elements of the string as \'1\'\nIf there are no zeros at all then the string can obviously not be modified\nIf there is atleast one zero then shift the leftmost zero by \'zk\' positions \n```\nclass Solution {\npublic:\n    string maximumBinaryString(string binary) {\n        int n = binary.size();\n        int z_count=0;  //count the number of zeros\n        int z_index=-1; //index of the leftmost zero that is why we start iterating from the right\n        for(int i=n-1;i>=0;i--) {\n         if(binary[i]==\'0\') {\n             z_count++;\n             z_index = i;\n             binary[i] = \'1\'; //changing all occurances to 1\n         }\n        }\n        if(z_index!=-1)  //to check if there is atleast 1 zero\n        {\n            binary[z_index+z_count-1] = \'0\'; //this is the only zero present\n            // -1 because the only zero is also included in zero count \n        }\n        return binary;\n    }\n};\n```\nI know it dosen\'t look neat with all the comments , but its a pretty simple solution :-)
['C', 'C++']