[Java] ✅7ms ✅ 100% ✅ Two Pointers ✅ FAST ✅ BEST
\n# Approach\n1. Traverse s with an index i and also keep track of a whiteBallIndex.\n2. If your current ball is white, you want to move it into correct positio
\n# Approach\n1. Traverse s with an index i and also keep track of a whiteBallIndex.\n2. If your current ball is white, you want to move it into correct position, at the beginning of the array, at indicated by whiteBallIndex.\n3. If ball is white, add i - whiteBallIndex to minSteps, simulating movement. Increment whiteBallIndex.\n4. Return min steps.\n\n# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public long minimumSteps(String s) {\n        long minSteps = 0;\n        int whiteBallIndex = 0;\n        for (int i = 0; i < s.length(); i++) {\n            if (s.charAt(i) == \'0\') {\n                minSteps += (i - whiteBallIndex);\n                whiteBallIndex++;\n            }\n        }\n        return minSteps;\n    }\n}\n```
['Two Pointers', 'Java']