Given an m x n grid of characters board and a string word, return true if word exists in the grid.
The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once.
board = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCCED"trueboard = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "SEE"trueboard = [["A","B","C","E"],["S","F","C","S"],["A","D","E","E"]], word = "ABCB"falsem == board.lengthn == board[i].length1 <= m, n <= 61 <= word.length <= 15board and word consists of only lowercase and uppercase English lettersExpected time complexity: O(m × n × 4^L)Run your code to see results
Use Cmd+Enter to run