My issue
My code
// Update the code below to solve this problem
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
string s;
cin >> s;
int flip0 = 0, flip1 = 0, flag0 = 0, flag1 = 1;
//converting to string starting with 0
for (int i = 0; i < s.length(); i++) {
if (flag0 != s[i] - 'a')
flip0++;
flag0 = 1 - flag0;
}
//converting to string starting with 1
for (int i = 0; i < s.length(); i++) {
if (flag1 != s[i] - 'a')
flip1++;
flag1 = 1 - flag1;
}
}
}
Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone