C++ easy
\n```\nclass Solution {\npublic:\n    int help(string s, int n){\n        int a[n];\n\n        for(int i = 0; i < n; i++) \n            a[i] = (s[i] == \'1\' ? 
\n```\nclass Solution {\npublic:\n    int help(string s, int n){\n        int a[n];\n\n        for(int i = 0; i < n; i++) \n            a[i] = (s[i] == \'1\' ? 1 : 0);\n\n\n        // Initialize prefix arrays to store\n        // number of changes required to put\n        // 1s at either even or odd position\n        int oddone[n + 1];\n        int evenone[n + 1];\n\n        oddone[0] = 0;\n        evenone[0] = 0;\n\n        for(int i = 0; i < n; i++)\n        {\n\n            // If i is odd\n            if (i % 2 != 0)\n            {\n\n                // Update the oddone\n                // and evenone count\n                oddone[i + 1] = oddone[i] +\n                                    (a[i] == 1 ? 1 : 0);\n                evenone[i + 1] = evenone[i] +\n                                      (a[i] == 0 ? 1 : 0);\n            }\n\n            // Else i is even\n            else\n            {\n\n                // Update the oddone\n                // and evenone count\n                oddone[i + 1] = oddone[i] +\n                                    (a[i] == 0 ? 1 : 0);\n                evenone[i + 1] = evenone[i] +\n                                      (a[i] == 1 ? 1 : 0);\n            }\n        }\n\n        // Initialize minimum flips\n        int minimum = min(oddone[n], evenone[n]);\n\n        // Check if substring[0, i] is\n        // appended at end how many\n        // changes will be required\n        for(int i = 0; i < n; i++)\n        {\n            if (n % 2 != 0)\n            {\n                minimum = min(minimum,\n                             oddone[n] -\n                              oddone[i + 1] +\n                             evenone[i + 1]);\n                minimum = min(minimum,\n                              evenone[n] -\n                              evenone[i + 1] +\n                               oddone[i + 1]);\n            }\n        }\n\n        // Return minimum flips\n        return minimum;\n}\n    int minFlips(string s) {\n        return help(s,s.size());\n    }\n};
['C']