Two Pointers vs. Counter
Two solutions are identical, but Counter could be easier to undertand.\n\n## Counter\nAs we go left-to-right, we count ones using cnt.\n\nWhen we see a zero, we
Two solutions are identical, but **Counter** could be easier to undertand.\n\n## Counter\nAs we go left-to-right, we count ones using `cnt`.\n\nWhen we see a zero, we need `cnt` swaps to move it in front `cnt` ones.\n\n**C++**\n```cpp\nlong long minimumSteps(const string &s) {\n    long long res = 0;\n    for (int i = 0, cnt = 0; i < s.size(); ++i) {\n        if (s[i] == \'1\')\n            ++cnt;\n        else\n            res += cnt;\n    }\n    return res;\n}\n```\n## Two Pointers\n**C++**\n```cpp\nlong long minimumSteps(const string &s) {\n    long long res = 0;\n    for (int i = 0, j = 0; i < s.size(); ++i)\n        if (s[i] == \'0\')\n            res += i - (j++);\n    return res;\n}\n```
['C']