Junior — Senior
Searching for a specified word in a two-dimensional grid
livecode
Task condition
Given a 2D grid of size m × n, filled with characters from the board, and a string word. Implement a function that returns True if the word can be constructed by moving through consecutive neighboring cells (neighbors are cells horizontally or vertically adjacent). The same cell cannot be used more than once.
Example 1: Input: board = [['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], word = "ABCCED" Output: True
Example 2: Input: board = [['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], word = "SEE" Output: True
Example 3: Input: board = [['A','B','C','E'],['S','F','C','S'],['A','D','E','E']], word = "ABCB" Output: False