Java, O(n), explained with very simple solution
Certain stuff you should understand\n1. There will be atmost one zero in the resulting answer\n2. ALL ZEROES MOVE TOWARDS the LEFT OF THE STRING\n3. This means 
Certain stuff you should understand\n1. There will be atmost one zero in the resulting answer\n2. ALL ZEROES MOVE TOWARDS the LEFT OF THE STRING\n3. This means that the position of that one zero, if it exists is starting zero + num_zeroes - 1. \n\nRefer to this link to see the diagram. \nhttps://leetcode.com/problems/maximum-binary-string-after-change/discuss/1007358/One-pass-bubble-up-solution\n```\nclass Solution {\n    public String maximumBinaryString(String binary) {\n        char[] array = binary.toCharArray();\n       // int i = 0; \n        int start = -1; int nums = 0; \n        for (int i = 0; i < array.length; i++){\n            if (array[i] == \'0\' && start == -1){start = i; nums += 1; }\n            else if (array[i] == \'0\') nums += 1; \n        }\n       StringBuilder string = new StringBuilder();\n       int pos = -1;\n        if (start != -1){\n            pos = start + nums -1; \n        }\n        for (int k = 0; k < array.length; k++){\n           if (k != pos)\n            string.append("1");\n            else \n                string.append("0");\n       \n       }\n        return string.toString();\n    }\n}\n```
[]