Given an m×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 (horizontally or vertically). 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"trueword="SEE"trueword="ABCB"falseboard[r][c] == word[0], launch DFS from itk == word.length → full match, return truefalsefalseWe explore every possible path depth-first. Marking the current cell as visited ('#') prevents revisiting it in the same path. When we backtrack (restore the cell), that cell becomes available again for other paths — ensuring correctness without extra space for a visited array.