Gettin WA in DISHOWN

Pls help in letting me know what are the test cases on which my code fails in the practice(easy)DISHOWN. I have tried all possible test cases… Pls help :frowning:
Here is my code

When you are checking this: else if(s[x-1]<s[y-1])
x-1 th dish may already be taken by some other chef, so take the parent of x-1 and the parent of y-1. Have a look at my code if you want.