Separate B&W Balls |Easiest Code ✅|Two Pointers✅|Java ✅| Beats 100%✅| Easy Explaination | Clean Code
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem involves finding the minimum steps to rearrange the chars of a string such 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves finding the minimum steps to rearrange the chars of a string such that all \'0\'s are grouped together in the leftmost part of the string. The key intuition is to iterate over the string and, for each occurrence of \'0\', calculate how far it needs to be shifted to its "correct" position (to the left).\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThe Approach is simple:\n\n1. Initialize a pointer i to keep track of where the next \'0\' should be placed.\n2. Iterate through the string with a pointer j.\n3. Each time we encounter \'0\' at position j, calculate the number of steps needed to move this \'0\' to position i (which is j - i).\n4. Increment i to point to the next available position for a \'0\'.\n5. Accumulate the total numbers of steps in answer and return it.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n) : making only one pass, n is length of string.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(1) : using a constant amount of extra space regardless of input size.\n\n# Code\n```java []\nclass Solution {\n    public long minimumSteps(String s) {\n        long i = 0;\n        long ans = 0;\n\n        for(int j = 0; j < s.length(); j++)\n        {\n            // if the current char is \'0\'\n            if(s.charAt(j) == \'0\')\n            {\n                // calculate steps req to move this \'0\' to position i\n                ans += j - i;\n                i++; // incr idx of i\n            }\n        }\n        return ans;\n    }\n}\n```\n\nIf you find this solution helpful, please upvote.\n:) >.<
['Two Pointers', 'String', 'Java']