Beats 95% || C++ || Two Pointers
Intuition\n Describe your first thoughts on how to solve this problem. \nUsing two pointers we will check if we are getting 1 before any 0, if yes, then we need
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing two pointers we will check if we are getting 1 before any 0, if yes, then we need to swap, so we will add distance between these two pointers in our answer.\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 []\n#define ll long long\nclass Solution {\npublic:\n    long long minimumSteps(string s) {\n        int n = s.size();\n        int i = 0, j = n-1;\n        ll ans = 0;\n        while(i < j){\n            if(s[j] == \'1\'){\n                j--;\n            }\n            else if(s[i] == \'0\'){\n                i++;\n            }\n            else{\n                ans += 1LL*(j-i);\n                i++;\n                j--;\n            }\n        }\n        return ans;\n    }\n};\nauto speedup = [](){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); return 0;}();\n```
['C++']