Sliding Window
The alternating string can start with \'0\' or \'1\'. We count how many replancements we need for these two cases in s0 and s1.\n\nBut do not stop there. Since 
The alternating string can start with \'0\' or \'1\'. We count how many replancements we need for these two cases in `s0` and `s1`.\n\nBut do not stop there. Since we can rotate our string, keep going and counting. However, this time we need to discard (subtract) missmatches that occurred before the rotated string. This can be done using the sliding window approach.\n\n**C++**\n```cpp\nint minFlips(string s) {\n    int res = INT_MAX, s0 = 0, s1 = 0, sz = s.size();\n    for (int i = 0; i < 2 * sz; ++i) {\n        s0 += s[i % sz] != \'0\' + i % 2;\n        s1 += s[i % sz] != \'0\' + (1 - i % 2);\n        if (i >= sz - 1) {\n            if (i >= sz) {\n                s0 -= s[i - sz] != \'0\' + (i - sz) % 2;\n                s1 -= s[i - sz] != \'0\' + (1 - (i - sz) % 2);\n            }\n            res = min(res, min(s0, s1));\n        }\n    }\n    return res;\n}\n```
['C']