← 返回 amazon 的题目列表Word Search with Modifications
类型:online_judge
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are those horizontally, vertically, or diagonally neighboring. Each cell can be reused. Cells outside the boundary of the grid are inaccessible. Implement a function exist(grid: List[List[str]], word: str) -> bool.
Example:
Input: grid = [['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E']], word = "ABCCED"
Output: true
Constraints:
1 <= grid.length, grid[i].length <= 200
1 <= word.length <= min(grid.length * grid[i].length, 10^3)
Example
Input
grid = [['A','B','C','E'],['S','F','C','S'],['A','D','E','E']]
word = "ABCCED"