问题描述
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 cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once.
Example:
1 | board = |
解题思路
回朔法,从board中每个元素出发遍历周围的四个元素,查看是否能组成部分答案,若能,则继续从该元素出发进行查找。
1 | class Solution: |