[Python 3] Counter swap for odd length string (384ms)
```\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        odd, even = defaultdict(int), defaultdict(int)\n        for i in range(len(s)):\n         
```\nclass Solution:\n    def minFlips(self, s: str) -> int:\n        odd, even = defaultdict(int), defaultdict(int)\n        for i in range(len(s)):\n            if i % 2:\n                odd[s[i]] += 1\n            else:\n                even[s[i]] += 1\n\n        ans =  min(odd[\'1\'] + even[\'0\'], odd[\'0\'] + even[\'1\'])\n        \n        # if even length string, odd and even position will not swap after each type-1 op\n        if len(s) % 2 == 0: return ans\n        \n        # if odd length string:\n        # 1. even and odd will swap after type-1 op\n        # 2. index 0 will still be even after type-1 op\n        for i in range(len(s)):\n            even[s[i]] -= 1\n            odd[s[i]] += 1\n            even, odd = odd, even\n            ans = min(ans, min(odd[\'1\'] + even[\'0\'], odd[\'0\'] + even[\'1\']))\n        \n        return ans
['Python', 'Python3']