由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - DP interview question
相关主题
变换单词题, 求JAVA答案My Microsoft Interview Questions
请问一道google面试题问一道少见的微软面试题。
print bst in level order dfs为什么是O(N)不应该是O(N^2)吗?Amazon电面经
发Facebook intern面经BFS traverse O(1) space?
请教一个DP的题问个老题
有人做过codility.com的题吗?上面经
amazon 1st phone interview请教一道Leetcode 题,多谢
about how to test a calculator program on computerleetcode jump game2
相关话题的讨论汇总
话题: dp话题: pyramid话题: linear话题: level话题: question
进入JobHunting版参与讨论
1 (共1页)
k*j
发帖数: 153
1
网上找来的题目
You are given a pyramid; the numbers for example is 2 on the first level, 3
-1 on the second level, 4 7 8 on the third, etc. How do you calculate the
maximum sub sequence of any path traversing the pyramid?
应该是用DP,目前只能想到O(k^2)的做法,k是level数。有没有比这个更快的做法,多
谢!
k*j
发帖数: 153
2
这题好像G也出过,麻烦大家看看

3

【在 k*j 的大作中提到】
: 网上找来的题目
: You are given a pyramid; the numbers for example is 2 on the first level, 3
: -1 on the second level, 4 7 8 on the third, etc. How do you calculate the
: maximum sub sequence of any path traversing the pyramid?
: 应该是用DP,目前只能想到O(k^2)的做法,k是level数。有没有比这个更快的做法,多
: 谢!

S**I
发帖数: 15689
3
BFS

3

【在 k*j 的大作中提到】
: 网上找来的题目
: You are given a pyramid; the numbers for example is 2 on the first level, 3
: -1 on the second level, 4 7 8 on the third, etc. How do you calculate the
: maximum sub sequence of any path traversing the pyramid?
: 应该是用DP,目前只能想到O(k^2)的做法,k是level数。有没有比这个更快的做法,多
: 谢!

r*******g
发帖数: 1335
4
http://www.mitbbs.com/article/JobHunting/31942529_3.html

3

【在 k*j 的大作中提到】
: 网上找来的题目
: You are given a pyramid; the numbers for example is 2 on the first level, 3
: -1 on the second level, 4 7 8 on the third, etc. How do you calculate the
: maximum sub sequence of any path traversing the pyramid?
: 应该是用DP,目前只能想到O(k^2)的做法,k是level数。有没有比这个更快的做法,多
: 谢!

k*j
发帖数: 153
5
多谢!

【在 r*******g 的大作中提到】
: http://www.mitbbs.com/article/JobHunting/31942529_3.html
:
: 3

e****i
发帖数: 393
6
Don't think this is a DP problem. Look into the optimal substructure
carefully.
l***i
发帖数: 1309
7
This is a DP problem and a linear time solution exists, assuming you can use
a linear size space. Since you have O(k^2) numbers, using O(k^2) time seems
acceptable.
j********x
发帖数: 2330
8
I dont think it is possible to have a algorithm linear to (k) (without pre-
processing)

use
seems

【在 l***i 的大作中提到】
: This is a DP problem and a linear time solution exists, assuming you can use
: a linear size space. Since you have O(k^2) numbers, using O(k^2) time seems
: acceptable.

D*******e
发帖数: 151
9
Compute in a bottom-up manner. For each element x, update it's sum by sum(x)
= x + max{sum(neighbor( x ))};
I think it's linear with the number of elements in the pyramid.
j********x
发帖数: 2330
10
It's k^2 elements un the tree
c******o
发帖数: 534
11
这个题什么意思,能举个例子吗?
1 (共1页)
进入JobHunting版参与讨论
相关主题
leetcode jump game2请教一个DP的题
用queue 做树的广度优先遍历,空间复杂度是多少?有人做过codility.com的题吗?
Level order traversal只让用一个Queue怎么做?amazon 1st phone interview
Tree的traversal也分BFS和DFS?about how to test a calculator program on computer
变换单词题, 求JAVA答案My Microsoft Interview Questions
请问一道google面试题问一道少见的微软面试题。
print bst in level order dfs为什么是O(N)不应该是O(N^2)吗?Amazon电面经
发Facebook intern面经BFS traverse O(1) space?
相关话题的讨论汇总
话题: dp话题: pyramid话题: linear话题: level话题: question