Algo For Alternating Characters Problem Statement
Passes the sample test cases mentioned in the statement.
int aC(vector<string> vec){
// cout<<"The passed vector is ";
// for(string s:vec){
// cout<<s<<" ";
// }cout<<endl;
int ans=0,vec_size=vec[0].size();
cout<<"The size of the overall vector is "<<vec.size()<<endl;
cout<<"The size of the vector is "<<vec_size<<endl;
for(int i=0;i<vec_size-1;i++){
cout<<"comparing "<<vec[0][i]<<" with "<<vec[0][i+1]<<endl;
if(vec[0][i]==vec[0][i+1]){
ans+=1;
}
}
return ans;
}
Comments
Post a Comment