You are given an m x n board of characters and a word.
Your task is to determine if the word can be constructed from sequentially adjacent cells on the board. Adjacent cells are defined as those that are horizontally or vertically neighboring.
Note that:
board may not be used more than once to form the word.board[i][j] and word consist of only lowercase English letters.Return true if the word exists in the board, otherwise return false.
board = [["c", "a"], ["d", "t"]]
word = "cat"
True
The word 'cat' can be formed from adjacent letters in the grid: c -> a -> t.
board = [["c", "a"], ["t", "d"]]
word = "cat"
False
The word 'cat' cannot be formed from adjacent letters in the grid. Note that letters must be adjacent horizontally or vertically, not diagonally.
board = [["t", "o"], ["s", "p"]]
word = "stops"
False
The word 'stops' cannot be formed from adjacent letters in the grid without reusing position twice.
board = [["c", "a"], ["d", "t"]]
word = "cat"
True