解题思路
回溯法DFS
代码
class Solution(object):
def exist(self, board, word):
"""
:type board...: List[List[str]]
:type word: str
:rtype: bool
"""
visited = [[False..., cur, i, j, visited):
if cur == len(word): # 如果到单词长度,结束。...= word[cur]:
return False # 越界或者是当前字母不等于word中对应位置字母
# 如果到这说明对应位置有,继续从此位置遍历四个方向...(board, word, cur + 1, i, j + 1, visited) or\
self.existRecu(board, word, cur + 1, i