One pass simple solution with explanation | Python 3
Intuition\n Describe your first thoughts on how to solve this problem. \nTo achieve the minimum swaps, we should start from the right most black ball that need 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo achieve the minimum swaps, we should start from the right most black ball that need to be moved. After moving, the next black ball on the left would still need to cross the white balls that the previous black ball had crossed.\n\n`11000` \n-> `10001` , swaps +3\n-> `00011` , swaps +3\n\n`101010`\n-> `101001`, swaps +1\n-> `100011`, swaps +2\n-> `000111`, swaps +3\n\nSo the problem can actually be transformed into: for each 1, how many zeroes on the right? (How many white balls it need to cross?)\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe start from the right end of the string, maintain a counter to record how many white balls (`\'0\'`) we have encountered. When we see a black ball (`\'1\'`), it would need to swap with `zero_count` white balls to reach the right group, so add `zero_count` to the answer.\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def minimumSteps(self, s: str) -> int:\n        ans = 0\n        zero_count = 0\n        for c in reversed(s):\n            if c == \'0\':\n                zero_count += 1\n            else:\n                ans += zero_count\n            \n        return ans\n            \n        \n```
['Python3']