See my submission,i don’t know what’s my mistake. Why I am getting two testcases wrong
Try
ABBBB
I think the output should be 1.
What I see, is you started coding before finalising your approach, and you are not comfortable with the language. You aren’t supposed to have lines like this
if((s[i]=='A' || s[i]=='G'|| s[i]=='T'|| s[i]=='C')&&(s[i+1]=='A' || s[i+1]=='G'|| s[i+1]=='T'|| s[i+1]=='C')){
c[j]=c[j]+1;
}else{
j++;
}
Instead use a set
set<char> valid={'A', 'C', 'G', 'T'};
if(valid.count(s[i]) && valid.count(s[i+1])){
//code
}
else{
//code
}
1 Like
I don’t know sets,maps or anything in stl .
I will try for ABBBB.
Thanks btw.
Got it correct,would have to learn these things.