observation based sliding window
\n    def minFlips(self, s: str) -> int:\n        """\n        111000\n        uee the first operation two times\n        100011\n        use second operation o
\n    def minFlips(self, s: str) -> int:\n        """\n        111000\n        uee the first operation two times\n        100011\n        use second operation on 2nd and last idx\n        101010\n        \n        is it something related to count of 1\'s and 0\'s?\n        \n        there is one mindblowing solution out there in discussion forum\n        \n        to handle removing operation what we can do is to append \n        curr string to same string again\n        \n        for eg s = 110\n        s = 110110\n        \n        now take two string s1 and s2\n        which start with 01 and 10 respectively and has alternate binary representation\n        s =  110|110\n        s1 = 101|010\n        s2 = 010|101\n        \n        now we will keep track of changed bits in window for both s1 and s2 \n        with s\n        \n        and windowsize will be of len original string\n        \n        count1 = positions need to flip to convert s to s1\n        count2 = positions need to flip to convert s to s2\n        for\n        idx         count1          count2\n        0             0               1\n        1             1               1\n        2             2               1\n        \n        whenever our idx goes beyound n\n            then just validate out of boundary ele\n            and if not same the reduce the count of flip\n        s =  1|101|10\n        s1 = 1|010|10\n        s2 = 0|101|01\n        3            2 => 3           0 => 0\n        and so on keep track of min count among both\n        \n        tc = O(2n)\n        sc = O(n)        \n        """\n        oldLen = len(s)\n        s += s\n        s1 = ""\n        s2 = ""\n        newLen = len(s)\n        for i in range(newLen):\n            if i % 2 == 0:\n                s1 += "0"\n                s2 += "1"\n            else:\n                s1 += "1"\n                s2 += "0"\n    \n        count1 = 0\n        count2 = 0\n        minFlips = newLen\n        for i in range(newLen):\n            if s[i] != s1[i]:\n                count1 += 1\n            if s[i] != s2[i]:\n                count2 += 1\n            if i >= oldLen:\n                if s[i - oldLen] != s1[i - oldLen]:\n                    count1 -= 1\n                if s[i - oldLen] != s2[i - oldLen]:\n                    count2 -= 1\n            if i >= oldLen - 1:\n                minFlips = min(minFlips,count1,count2)\n        return minFlips
['Sliding Window', 'Simulation', 'Python']