Given a 2-D grid of characters, and a list of words to be searched in this grid , output the starting indexes of grid from which each word starts. Words can be searched in all 8 directions but have to be in straight line.
Also it was specifically written that write optimal solution where we should not be traversing or processing grid for each word i.e suppose there are n words to be searched, you should not traverse grid n times.
Example input:
Grid=
[ABCD
GAAE
AOTW
ANDY]
words: [CAT,ANDY,DOG]
Output:
CAT 0 2
ANDY 3 0
DOG 3 2