Sliding window
Golang.\n\nfunc minFlips(s string) int {\n    buf := make([]bool, len(s)<<1)\n    for i := range s {\n        buf[i] = s[i] == \'1\'\n    }\n    copy(buf[len(s)
Golang.\n```\nfunc minFlips(s string) int {\n    buf := make([]bool, len(s)<<1)\n    for i := range s {\n        buf[i] = s[i] == \'1\'\n    }\n    copy(buf[len(s):], buf[:len(s)])\n    \n    return min(count(buf, 0), count(buf, 1))\n}\n\nfunc min(a, b int)int {\n    if a < b {return a}\n    \n    return b\n}\n\nfunc count(buf []bool, b int) int {\n    r := 0\n    cnt := 0\n    \n    for ; r < len(buf)>>1; r++{\n        if r&1 == b {\n            if buf[r] {cnt++}\n        }else{\n            if !buf[r] {cnt++}\n        }\n    }\n    \n    res := cnt\n    for l := 0; r < len(buf); r++ {\n         if r&1 == b {\n            if buf[r] {cnt++}\n        }else{\n            if !buf[r] {cnt++}\n        }\n        if l&1 == b {\n            if buf[l] {cnt--}\n        }else{\n            if !buf[l] {cnt--}\n        }\n        l++\n        res = min(res, cnt)\n    }\n    \n    return res\n}\n```
[]