Simple solution - C++ [consisting of 2 traversals of the string]
Intuition\n Describe your first thoughts on how to solve this problem. \nSimply moving all 1\'s to the right and all 0\'s to the left and counting the number of
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSimply moving all 1\'s to the right and all 0\'s to the left and counting the number of moves required in it.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFor 1\'s, traverse from right to left on the string, and count the number of moves required to move all 1\'s to the right. \nFor 0\'s, traverse from left to right on the string, and count the number of moves required to move all 0\'s to the left.\n\nKeeping the count of 1\'s and 0\'s in each traversal to adjust the number of moves because of the already correctly placed 0\'s and 1\'s.\n\nAt the end, since we are doing the swapping operation, so the whole move count needs to be halved.\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       long long ans = 0;\n       int n = s.size(), cnt_zero = 0, cnt_one = 0;\n\n        for(int i=n-1;i>=0;i--)\n            if(s[i] == \'1\') {\n                ans += (n-i-1-cnt_one);\n                cnt_one++;\n            }\n        for(int i=0;i<n;i++) {\n            if(s[i] == \'0\') {\n                ans += (i-cnt_zero);\n                cnt_zero++;\n            }\n        }\n        return ans/2;\n    }\n};\n```
['C++']