[Java] Time: O(n) | Space: 0(1) | 100% faster than other solutions
class Solution {\n    public String maximumBinaryString(String binary) {\n         \n        int count=0,start=0;\n        //count the no of zeroes\n        for
class Solution {\n    public String maximumBinaryString(String binary) {\n         \n        int count=0,start=0;\n        //count the no of zeroes\n        for(int i=0;i<binary.length();i++){\n            if(binary.charAt(i)==\'0\'){\n                //find the occurence of first zero\n                if( count==0)\n                    start=i;\n                 count++;\n            } \n        }\n        String res="";\n        StringBuilder str \n            = new StringBuilder(); \n        \n        //if the occurence of zero is less than 2 then no combination possible.\n        if(count<2)\n            return binary;\n        count=count+start;\n        for(int i=0;i<binary.length();i++){\n            if(i==count-1)\n                str.append("0"); \n            else\n           str.append("1"); \n        }\n       return str.toString();\n    }\n}
[]