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.
For example,
Given board =
[ ['A','B','C','E'], ['S','F','C','S'], ['A','D','E','E'] ]
word = "ABCCED", -> returns true,
word = "SEE", -> returns true,
word = "ABCB", -> returns false.
思路:
二维数组从第一行开始,每个元素作为字符串的开始进行比对,直到比对成功
本文介绍了一个二维网格中查找指定单词的问题。通过从每个单元格出发,递归地寻找与目标单词匹配的路径,确保相邻字母可以水平或垂直连接,且同一单元格字母不可重复使用。文章提供了具体的例子来说明算法如何运作。
1090

被折叠的 条评论
为什么被折叠?



