今際の国の呵呵君
Wednesday, September 27, 2017
[LeetCode]Word Search
很典型的backtracking问题,从每个cell开始查看能不能找到path match给定的string。假设board size 为m * n,给定string长度为d,时间复杂度Worst case O(m * n * d),空间复杂度O(d)(递归深度),我们在原board上标记当前元素是否被visited过。代码如下:
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment