Back to problems

Word Search

Algorithm · Uber · Medium

You are given a rectangular grid of letters (the board) and a target word. Determine whether the word can be constructed by starting at any cell and moving to adjacent cells (up, down, left, right) without revisiting any cell. The path must spell out the word exactly in order. Return true if such a path exists, otherwise false. Examples Example 1 Output: true Explanation: Start at (0,0) 'A', move right to (0,1) 'B', move down to (1,1) 'E', move down to (2,1) 'H', move right…

Checking your access…