Greedy Intuitive Solution. JAVA O(n)
Intuition\n Describe your first thoughts on how to solve this problem. We need to push the leftmost 0 as far to the right as possible. We can always move this 0
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->We need to push the leftmost 0 as far to the right as possible. We can always move this 0 to the 1 index to the right, repeating the given operations from the next zero to the left. By doing so, we can observe the pattern: we use one zero to push the leftmost zero to the right, and the total number of zeroes decreases by 1. Therefore, we just need to find the position of the leftmost zero and count all the other zeroes. The final string would consist of all ones, except for the one zero that we pushed as far as we had other zeroes. So, if the index of the leftmost zero is i, and we have k zeroes to spare, the resulting position of the 0 would be [i + k].\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGreedy\n\n# Complexity\n- Time complexity:\n- O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n- O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public String maximumBinaryString(String binary) {\n        int n = binary.length();\n        char[] chars = binary.toCharArray();\n        int firstZero = -1;\n        int shift = 0;\n        for(int i = 0; i < n; i++){\n            if(chars[i] == \'0\'){\n                if(firstZero == -1){\n                    firstZero = i;\n                }else shift++;\n            }\n            \n        }\n        if(firstZero == -1){\n            return binary;\n        }\n        char[] ans = new char[n];\n        Arrays.fill(ans, \'1\');\n        ans[firstZero + shift] = \'0\';\n        return  new String(ans);\n    }\n}\n```
['Java']