Can someone explain this question? (WORDGRID)

Can someone explain their own solution(code)?
https://www.codechef.com/problems/WORDGRID