Chef and the string

Can anybody please explain this problem Chef and the String. I am not able to understand how the output is generated?

Subsequence is any sequence in string that you may get by skipping 0/more characters from any position
Example string : THE The possible subsequences are :

T,H,E,TH,TE,HE,THE.

Now whenever a subsequence is chosen , it is removed from the string.

All you have to do is find no of subsequences “CHEF” that you can find in given string.

my code is showing wrong ans… plzz can any one tell what is wrong in this…

https://www.codechef.com/viewsolution/8273089

@deeksha_garg Your code gives wrong answer for test case EFCH. It says 1 but answer is zero. Subsequence means you need to delete CHEF in a way that order of C,H,E,F is preserved. You can have a look at this

now also it is showing wrong answer:https://www.codechef.com/viewsolution/8279449

@deeksha_garg Your code is not producing the right answer for the first example testcase. Print out all values of a after each new char and you will probably see whats going wrong.