由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - leetcode: word search backtracking 复杂度
相关主题
Leetcode online judge的word search是不是用dp?Leetcode Combination Sum复杂度
大牛看过来~Word Search这题的优化解是?问问 leetcode 新题
leetcode word ladder 2 的大测试该如何过啊?请教recursive backtracking问题的时间复杂度的分析
有最简法code么这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.
怎么估计backtracking的复杂度?求问一题
how to solve this google interview question再来问一下word search的时间复杂度分析
找最大、第二大元素问题问一下sorting
问一道data structure的面试题一道面试算法题
相关话题的讨论汇总
话题: word话题: 复杂度话题: cell话题: board话题: adjacent
进入JobHunting版参与讨论
1 (共1页)
h**o
发帖数: 548
1
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.
我知道有人问过了。没答案。
我觉得time 复杂度是m*n*4^(k-1). 也就是m*n*4^k.
m X n is board size, k is word size.
space 复杂度 是: 4^k (recursive)+ m*n (to mark visited board cell)
是这样吗?
a*****u
发帖数: 1712
2
时间复杂度我跟你想的一样。
空间复杂度好像不对,recuision最深是k层,recursive部分空间复杂度应该是O(k)

★ 发自iPhone App: ChineseWeb 7.8

【在 h**o 的大作中提到】
: 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.
: 我知道有人问过了。没答案。
: 我觉得time 复杂度是m*n*4^(k-1). 也就是m*n*4^k.
: m X n is board size, k is word size.
: space 复杂度 是: 4^k (recursive)+ m*n (to mark visited board cell)
: 是这样吗?

h**o
发帖数: 548
3
对应该是k + mn

【在 a*****u 的大作中提到】
: 时间复杂度我跟你想的一样。
: 空间复杂度好像不对,recuision最深是k层,recursive部分空间复杂度应该是O(k)
:
: ★ 发自iPhone App: ChineseWeb 7.8

h**o
发帖数: 548
4
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.
我知道有人问过了。没答案。
我觉得time 复杂度是m*n*4^(k-1). 也就是m*n*4^k.
m X n is board size, k is word size.
space 复杂度 是: 4^k (recursive)+ m*n (to mark visited board cell)
是这样吗?
a*****u
发帖数: 1712
5
时间复杂度我跟你想的一样。
空间复杂度好像不对,recuision最深是k层,recursive部分空间复杂度应该是O(k)

★ 发自iPhone App: ChineseWeb 7.8

【在 h**o 的大作中提到】
: 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.
: 我知道有人问过了。没答案。
: 我觉得time 复杂度是m*n*4^(k-1). 也就是m*n*4^k.
: m X n is board size, k is word size.
: space 复杂度 是: 4^k (recursive)+ m*n (to mark visited board cell)
: 是这样吗?

h**o
发帖数: 548
6
对应该是k + mn

【在 a*****u 的大作中提到】
: 时间复杂度我跟你想的一样。
: 空间复杂度好像不对,recuision最深是k层,recursive部分空间复杂度应该是O(k)
:
: ★ 发自iPhone App: ChineseWeb 7.8

l*******t
发帖数: 79
7
能不能解释一下那个4^(k-1)是怎么来的 谢谢!
1 (共1页)
进入JobHunting版参与讨论
相关主题
一道面试算法题怎么估计backtracking的复杂度?
boggle game是不是只有backtracking的解法?how to solve this google interview question
写了一个Queens的backtrack 大牛帮我看看找最大、第二大元素问题
suduku solver这道题写代码有点难啊。问一道data structure的面试题
Leetcode online judge的word search是不是用dp?Leetcode Combination Sum复杂度
大牛看过来~Word Search这题的优化解是?问问 leetcode 新题
leetcode word ladder 2 的大测试该如何过啊?请教recursive backtracking问题的时间复杂度的分析
有最简法code么这种backtracking的问题怎么算时间复杂度?比如palindrom patitioning.
相关话题的讨论汇总
话题: word话题: 复杂度话题: cell话题: board话题: adjacent