What is the problem in my code?

I am not able to figure out the problem in my approach, could you please help, it is giving correct output in given test cases

you can check the corrected code here: https://ide.codingblocks.com/s/209619
the main issue was you missed this line of question:
β€œAnd if no such words are available for a given search word, add this word to your dictionary.” last line of problem statement.

thanks