[C++] O(N) Time | O(1) Space | Intuitive
fz is a 2x2 array having the following structure\nfz[0][0] -> # of zeros in even indices\nfz[0][1] -> # of ones in even indices\nfz[1][0] -> # of zeros in odd i
fz is a 2x2 array having the following structure\nfz[0][0] -> # of zeros in even indices\nfz[0][1] -> # of ones in even indices\nfz[1][0] -> # of zeros in odd indices\nfz[1][1] -> # of ones in odd indices\n\nlet n = length of string\nif n is even, type-1 operations don\'t matter at all.\nso we can simply return the min-flips at current stage.\n\nMain problem is when n is odd, all characters shift from even positions to odd positions and vice-versa, except the first, it stays in the even position only and rest are swapped\n\n```\nclass Solution {\npublic:\n    int minFlips(string s) {\n        int n = s.size();\n        array<array<int, 2>, 2> fz = {};\n    \n        for(int i = 0; i < n; ++i) {\n            fz[i % 2][s[i] - \'0\']++;\n        }\n        \n        int res = INT_MAX;\n  \n        if(n % 2 == 0)\n            return min(fz[0][0] + fz[1][1], fz[0][1] + fz[1][0]);\n        \n        for(int i = 0; i < n; ++i) {\n            swap(fz[0][0], fz[1][0]);\n            swap(fz[0][1], fz[1][1]);\n            \n            if(s[i] == \'0\') {\n                fz[0][0]++;\n                fz[1][0]--;\n            } else {\n                fz[0][1]++;\n                fz[1][1]--;\n            }\n            \n            res = min(res, min(fz[0][0] + fz[1][1], fz[0][1] + fz[1][0]));\n        }\n        \n        return res;\n    }\n};\n```
[]