my sol :)
Intuition\nSimple\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nSimple\n Describe your approach to solving the problem. \n\n# Com
# Intuition\nSimple\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSimple\n<!-- Describe your approach to solving the problem. -->\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\n{\npublic:\n    typedef long long ll;\n\n    int minFlips(string& s)\n    {\n        ll n = s.size(), bk0, bk1, fr0, fr1;\n        bk0 = bk1 = fr0 = fr1 = 0;\n\n        for (ll i = n - 1; i >= 0; i--)\n        {\n            ll oddness = ((n - i) & 1), // backoddness\n               val = s[i] - \'0\';\n\n            if (oddness == val)\n                bk0++;\n            if (oddness != val)\n                bk1++;\n        }\n\n        ll ans = min(bk0, bk1);\n        if (!(n & 1))\n            return ans;\n\n        for (ll i = 0; i < n - 1; i++)\n        {\n            ll oddness = ((n - i) & 1), // backoddness\n               val = s[i] - \'0\';\n\n            bk0 -= (oddness == val);\n            bk1 -= (oddness != val);\n\n            oddness = (i & 1); // frontoddness\n            fr0 += (oddness != val);\n            fr1 += (oddness == val);\n\n            ans = min({ans, fr0 + bk1, fr1 + bk0});\n        }\n\n        return ans;\n    }\n};\n```
['C++']