
Given a 2D board of characters and a string word, return True if the 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 in the word.
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
1 <= board.length, board[i].length <= 61 <= word.length <= 15board = [['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E']], word = 'ABCCED'OutputTrueWhyThe word 'ABCCED' can be formed by following the path A->B->C->C->E->D in the grid.board = [['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E']], word = 'ABCB'OutputFalseWhyThe word 'ABCB' cannot be formed as the second 'B' cannot be reached after the first 'B'.1 <= board.length, board[i].length <= 61 <= word.length <= 15All inputs consist of lowercase and uppercase English letters only.def exist(board, word):