Simple and clear solution. Time O(n), space O(1).
\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        cnt0 = s[::2].count(\'0\') + s[1::2].count(\'1\')\n        cnt1 = len(s) - cnt0\n        ans 
```\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        cnt0 = s[::2].count(\'0\') + s[1::2].count(\'1\')\n        cnt1 = len(s) - cnt0\n        ans = min(cnt0, cnt1)\n        if not len(s) % 2:\n            return ans\n        for n in s:\n            cnt0, cnt1 = cnt1, cnt0\n            if n == \'1\':\n                cnt1 += 1\n                cnt0 -= 1\n            else:\n                cnt0 += 1\n                cnt1 -= 1\n            ans = min(cnt0, cnt1, ans)\n        return ans\n```
['Python3']