Find the string in grid || Test case 9 of my solution if failing while exact custom case is correct

Problem link: https://practice.geeksforgeeks.org/problems/find-the-string-in-grid0111/1#

solution link:
https://discuss.geeksforgeeks.org/comment/20f45b155034dbbf282c63a042f2a160

Hey @danishrehman288 Testcase 9 is failling bcoz they said zigzag pattern is not allowed means if you have started searching in horizontal direction then whole word should be in horizontal direction you cannot move from horizontal to vertical then to diagonal it not allowed.
for. test case :
6 10
abaebeeecc
abecbdecad
eccccadacb
eeadddcbbb
bdbacabbdd
cccdaeaceb
bed
your code gives 5 3
bcoz when when we start from 5 3 it goes to left then up which is not allowed. therefore answer should be -1;

So why while testing in custom test case it is giving me -1

Hey @danishrehman288 no it is not.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.