Please help me in MANYCHEF <— problem <–my solution

Getting WA, i spent like 2 hours maybe even 3, I am unimaginably slow!

I cannot tell what is wrong with your code since I code in C++.
But you can solve this problem by

iterating over the string from the last and taking 4 characters as long as we can do this
and check whether we can replace it with “CHEF”.

if (((s[i-3] == '?' || s[i-3] == 'C') && (s[i-2] == '?' || s[i-2] == 'H') && (s[i-1] == '?' || s[i-1] == 'E') && (s[i] == '?' || s[i] == 'F')) && i >= 3)

else ‘?’ should be replaced by ‘A’.

Sorry, If you already know this.

You can refer to editorial : here

Thank you for replying, i tried same approach- in the inner for loop inside while. That didn’t work!

but surprisingly if i hardcoded that like you said it worked…


thanks a ton!