java100 % faster
\n\n        int n=s.length(); \n        s=s+s;\n        char t[]=s.toCharArray();\n        char  a[]=new char[n+n];\n        char b[]=new char[n+n];\n        fo
\n\n        int n=s.length(); \n        s=s+s;\n        char t[]=s.toCharArray();\n        char  a[]=new char[n+n];\n        char b[]=new char[n+n];\n        for(int i=0;i<n+n;i++)\n        {\n            if(i%2==0)\n            {\n                a[i]=\'1\';\n                b[i]=\'0\';\n            }\n            else\n            {\n                a[i]=\'0\';\n                b[i]=\'1\';\n            }\n        }\n        int f=0,sec=0,ans=Integer.MAX_VALUE;\n        for(int i=0;i<n+n;i++)\n        {\n            if(a[i]!=t[i])\n                f++;\n            if(b[i]!=t[i])\n                sec++;\n            if(i>=n)\n            {\n                if(a[i-n]!=t[i-n])\n                    f--;\n                if(b[i-n]!=t[i-n])\n                    sec--;\n            }\n            if(i>=n-1)\n                ans=Math.min(ans,Math.min(f,sec));\n                \n        }\n        return ans;\n        \n \n
['Sliding Window', 'Java']