Python 2-pointer/Sliding Window O(N) time O(1) space
\n\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        wrongBits = 0\n        length = len(s)\n        for i in range(length):\n            wrongB
\n```\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        wrongBits = 0\n        length = len(s)\n        for i in range(length):\n            wrongBits += (i % 2 == 0 and s[i] == "1") or (i % 2 == 1 and s[i] == "0")\n        i = 0\n        j = 0\n        best = min(wrongBits, length-wrongBits)\n        while (j < length):\n            wrongBits -= (i % 2 == 0 and s[i] == "1") or (i % 2 == 1 and s[i] == "0")\n            wrongBits += (j % 2 == length % 2 and s[j] == "1") or (j % 2 == 1 - (length % 2) and s[j] == "0")\n            best = min(best, wrongBits, length-wrongBits)\n            i += 1\n            j += 1\n        return best\n  ```
[]