Eight-Direction Word Search
Problem statement
Given a rectangular grid of characters encoded as equal-length strings and a word, return whether the word can be formed from sequentially adjacent cells. Each step may move horizontally, vertically, or diagonally, and one cell cannot be reused within a path.
Function
wordExistsEightDirections(board: String[], word: String) → booleanExamples
Example 1
board = ["ABCE","SFCS","ADEE"]word = "ABCCED"return = trueExample 2
board = ["AB","CD"]word = "AD"return = trueThe diagonal move is allowed.
Constraints
1 <= board.length, board[i].length <= 50.1 <= word.length <= 50.- Board cells and the word contain English letters.