Amazon | Interview | Print all possible words from a 2d array
Anonymous User
838

Question: Given a 2d matrix words, print all the words which are present in an English Dictionary. The words in the dictionary need not be in a straight line i.e you need to consider all the 8 possible directions.
For eg.
words= [["M","Y"],["N","A"]]
Output: ["MY","MAN","AN","ANY","MANY"]

Any idea how to solve this in the most optimum way?

**Update: I solved using Backtracting Technique and I was selected. **

Comments (1)