rust 7 ms
rust\n\nuse std::cmp::min;\nimpl Solution {\n    pub fn min_flips(mut s: String) -> i32 {\n        let len = s.len();\n        let mut chars = s.chars().collect
```rust\n\nuse std::cmp::min;\nimpl Solution {\n    pub fn min_flips(mut s: String) -> i32 {\n        let len = s.len();\n        let mut chars = s.chars().collect::<Vec<char>>();\n        let ch = [\'0\',\'1\'];\n        let mut cnt = 0;\n        for i in 0..len {\n            if chars[i] != ch[i%2] {\n                cnt+=1;\n            }\n        }\n        let mut ans = min(cnt,len as i32 - cnt);\n        for i in 0..len {\n            if chars[i] != ch[i%2] {\n                cnt-=1;\n            }\n            if chars[i] != ch[(i+len)%2] {\n                cnt+=1;\n            }\n            ans = ans.min(min(cnt,len as i32 - cnt));\n        }\n        return ans;\n    }\n}\n\n\n```
['Rust']