My issue
I didn’t understand the problem after seeing solution vedio also someone explain in detail with examples
My code
# cook your dish here
Problem Link: Alternating Binary String Practice Coding Problem - CodeChef
I didn’t understand the problem after seeing solution vedio also someone explain in detail with examples
# cook your dish here
Problem Link: Alternating Binary String Practice Coding Problem - CodeChef
@vickyvarun1316
the problem is quite simple to have to convert the given string into strings like 01010101… or 10101010… which is no two adjacent element are same.
To achieve this we have to perform the operation like choose any index and flip all the element from that index till the end of the string .
plzz refer my c++ code for better understanding of the logic.
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string s;
cin>>s;
int ans=0;
for(int i=1;i<n;i++)
{
if(s[i]==s[i-1])
ans++;
}
cout<<ans<<endl;
}
return 0;
}