[Java],sliding window ,O(N) ,6ms ,100% faster
\nclass Solution {\n    public int minFlips(String s) {\n        char [] arr=s.toCharArray();\n        int len=arr.length;\n        char [] odd=new char[2*arr.l
```\nclass Solution {\n    public int minFlips(String s) {\n        char [] arr=s.toCharArray();\n        int len=arr.length;\n        char [] odd=new char[2*arr.length];\n        int flag=0;\n        for(int i=0;i<odd.length;i++){\n            odd[i]=(char)(\'0\'+flag);\n            flag=1-flag;\n        }\n        int val=0;\n        for(int i=0;i<arr.length;i++){\n            val+=odd[i]^arr[i];\n        }\n        min=Math.min(val,len-val);\n        for(int i=len;i<2*len;i++){\n            val=val-(arr[i-len]^odd[i-len]);\n            val+=arr[i-len]^odd[i];\n            min=Math.min(min,Math.min(val,len-val));\n        }\n        return min;\n    }\n}\n```
[]