Efficient Approach || Faster || 0 ms || C++ || Separate Black and white balls
Intuition\n Describe your first thoughts on how to solve this problem. \nThere is a two balls, black as 1 and white as 0 we have to move the black balls to righ
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere is a two balls, black as 1 and white as 0 we have to move the black balls to right and white balls to the left. We have to find the minimum total no. of steps taken by the balls to move.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize the two variables count and ans as 0.\n2. Count variable will keep track of the no. of black balls 1\'s.\n3. And, ans will store the total no. of steps taken by black balls to move right.\n4. Store string s to i, and if i == 1 then increment count.\n5. Else, store the sum of ans & count in ans.\n6. At last, return the ans.\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```cpp []\nclass Solution {\npublic:\n    long long minimumSteps(string s) {\n\n      long long count = 0;\n      long long ans = 0;\n\n      for(auto i:s)\n      {\n        if(i == \'1\')\n        {\n            count++;\n        }\n        else\n        {\n            ans += count;\n        }\n      }\n      return ans;\n    }\n};\n```
['Two Pointers', 'String', 'Greedy', 'C++']