Pergunta de entrevista da empresa ThousandEyes

Given a matrix of characters and an API Dictionary.isWord(String s), which return true/false. Word can be formed only horizontally/vertically from the matrix not diagonally. Return a list of valid words that can be formed from the matrix. ['a','b','c','d'] ['t','p','q','x'] ['a','m','a','t'] ['d','a','c','d'] Your program should return ["am", "dam","cat"]