I got correct output for the given test case when it comes it's failing

Problem : CHEFFAV
Solution is:CodeChef: Practical coding for everyone
I have no idea where I’m failing

1 Like

Hi @harsha_1999s

I hope you find this video helpful in explaining the logic.
CHEFFAV | FAVOURITE STRING OF CHEF | December CodeDrive 2021 | Problem Solutions | CodeChef

The simple way to do it in python would be as follows

# cook your dish here
t=int(input())
for i in range(t):
    n=int(input())
    a=input()
    x=a.index("code")
    y=a.index("chef")
    if x<y:
        print("AC")
    else:
        print("WA")

This code basically checks for the index of the first occurrence of “code” & “chef”, and afterwards you compare the index of both and print the result.

If you found this useful, check out our other problems and other upcoming contests!
CodeChef Contests
Solve more problems on CodeChef