r**********o 发帖数: 50 | 1 Word Search这题的优化解是?看面经里也有经常考到,但是手边的资料好像只有暴力
解!!
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 =
[
["ABCE"],
["SFCS"],
["ADEE"]
]
word = "ABCCED", -> returns true,
word = "SEE", -> returns true,
word = "ABCB", -> returns false.
请大牛出场~~ | l*******g 发帖数: 82 | 2 我不是大牛!
我觉得可以用suffixtree来做,或者A* search
好久没碰算法了,哈哈。 | r**********o 发帖数: 50 | |
|