C++ | 4 Lines Code | O(N) Time Complexity
\n# Approach\nAs you iterate through the string:\n\n-  Track how many 1s you\'ve encountered.( long long count1)\n- When you find 0, you need to swap it with 1s
\n# Approach\n**As you iterate through the string:**\n\n-  Track how many 1s you\'ve encountered.( long long count1)\n- When you find 0, you need to swap it with 1s you encountered till now, so add count1 to ans (ans += count1). \n\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, count1 = 0;\n        for(int i = 0; i< s.size(); i++){\n            if( s[i] == \'0\')ans += count1;\n            else count1++;  \n        }\n        return ans;\n    }\n};\n```
['C++']