A word game shows a grid of letter tiles, given as board, an array of equal-length strings. The player spells a word by starting on any tile and moving to a tile directly above, below, left, or right each time. A tile can be used at most once per word.
Write canTrace(board, word) that returns true if word can be spelled this way, and false otherwise.
Input: board = ["CAT","XOR","DOG"], word = "CAT" Output: true
The top row spells CAT from left to right.
Input: board = ["CAT","XOR","DOG"], word = "COG" Output: false
The only C has neighbors A and X, never O.
1 <= board.length, board[0].length <= 61 <= word.length <= 15Run tries your code on the examples. Submit runs every test, including hidden edge cases and big inputs that check your code is fast enough, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #311 Trace a Word in a Letter Grid. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.