C++
```class Solution {\npublic:\n    int minFlips(string s) \n    {\n        int zO=0,zE=0,oO=0,oE=0,n=s.length();\n        \n        for(int i=0; i < n;i++)\n    
```class Solution {\npublic:\n    int minFlips(string s) \n    {\n        int zO=0,zE=0,oO=0,oE=0,n=s.length();\n        \n        for(int i=0; i < n;i++)\n        {\n            oO = (i&1) && (s[i]-\'0\')  ? oO+1 : oO;\n            oE = !(i&1) && (s[i]-\'0\') ? oE+1 : oE;\n            zO = (i&1) && !(s[i]-\'0\') ? zO+1 : zO;\n            zE = !(i&1) && !(s[i]-\'0\')? zE+1 : zE;\n        }\n        \n        int ans= min(zO+oE,zE+oO);\n        \n        if((n&1)==0)\n            return ans; \n        \n        for(int i=0;i < n;i++)\n        {\n            swap(zO,zE);\n            swap(oO,oE);\n            \n            if(s[i]-\'0\')\n            {\n                oE++;\n                oO--;\n            }\n            else \n            {\n                zE++;\n                zO--;\n            }\n            \n            ans=min(ans,min(zO+oE,zE+oO));\n        }\n        \n        return ans;\n    }\n};
[]