# CHRL2 - Editorial

Can anyone explain why my code gets WA
I think it is right.

#include <bits/stdc++.h>
using namespace std;

int main() {

``````string s;
cin >> s;
int a[4] = {};
for(int i=0;i<s.size();i++)
{
if(s[i]=='C')
a[0]++;
else if(s[i]=='H' && a[0]>a[1])
a[1]++;
else if(s[i]=='E' && a[0]>a[2])
a[2]++;
else if(s[i]=='F' && a[0]>a[3])
a[3]++;
}

cout << a[3] <<endl;
return 0;
``````

}

s=input()
d={}
for i in s:
if i==βCβ:
if d.get(i)==None:
d[i]=1
else:
d[i]+=1
if d.get(βCβ)!=None:
if d.get(i)==None:
d[i]=1
else:
if d[i]<d[βCβ]:
d[i]+=1

print(min(d.values()))
i dont know where my code is failing.`s=input()
d={}
for i in s:
if i==βCβ:
if d.get(i)==None:
d[i]=1
else:
d[i]+=1
if d.get(βCβ)!=None:
if d.get(i)==None:
d[i]=1
else:
if d[i]<d[βCβ]:
d[i]+=1
print(d)
print(min(d.values()))

`

ya we need the letter to be in same order as in CHEF

the route in chef is C > H > E > F
you are always chking possibility of route directly from
C to E in 1st else if block | correct
C to H in 2nd else if block | incorrect , change it
C to F in 3nd else if block | incorrect , change it

ONLY THESE MINUTE CHANGES AND YOUR CODE WILL BE PERFECT FOR ALL TEST DATA

GETTING CORRECT FOR SUBTASK 1 TASK 0 , SUBTASK 2 TASK 3 β¦PLS HELP ME
@usernameharsh @vlew @zygon @deepu_codes @goodwine
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s,s2="";
cin>>s;
int cnt=0;
s2.append(s,0,1);
for(int i=1;i<s.length();i++)
{
if(s[i]==s[i-1]) {}
else
s2.append(s,i,1);
}
for(int i=0;i<s2.length();i++)
{
if(s2[i]==βCβ&&s2[i+1]==βHβ&&s2[i+2]==βEβ&&s2[i+3]==βFβ)
{
cnt++; i+=2;
}
}
//cout<<s2<<endl;
cout<<cnt<<endl;
return 0;
}

My code is pretty much equivalent to yours, and I get a WA (Wrong Answer) when I submit it. I canβt figure out which string would give me a wrong answer. Did you ever figure out what is wrong with yours?