由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 一道大公司诡异的complete binary tree max sum of 2 nodes 题
相关主题
binary tree, sum of 2 nodes == given numberCareercup 4.9解释一下?
amazon一道面试题感觉leetcode的OJ有点太偏重DP了
问个amazon面试题这个题做的对吗?
full or complete binary tree的问题求教一道老题
问道题,binary tree里有一个有indegree 2这个Binary Tree的题来看看
Lowest common ancestor of two nodes of Binary Tree讨论个Binary search tree的题目
onsite面试题一道请问一个简单的面试题
判断树为binary search tree 有多少种解法amazon first phone interview, rejected
相关话题的讨论汇总
话题: nodes话题: binary话题: sum话题: tree话题: complete
进入JobHunting版参与讨论
1 (共1页)
d***d
发帖数: 99
1
一道大公司诡异的complete binary tree max sum of 2 nodes 题
当场 40min white board 给出了O(N2) 的解法,对方表示赞许,但是没时间optimize
了。直觉告诉我应该有NlogN的解法。大牛指点下。
具体如下:
given one complete binary tree, with positive and identical values in all
nodes.
Find 2 nodes, such that:
sum of their path nodes to root (identical nodes will count only once) are maximum.
s*****y
发帖数: 897
2
looks the same as this one:
look at 1337's code
http://www.mitbbs.com/article_t/JobHunting/31898169.html
s*****y
发帖数: 897
3
actually it is o(n) not only o(nlogn);

【在 s*****y 的大作中提到】
: looks the same as this one:
: look at 1337's code
: http://www.mitbbs.com/article_t/JobHunting/31898169.html

r*******y
发帖数: 1081
4
deepest nodes?

optimize
maximum.

【在 d***d 的大作中提到】
: 一道大公司诡异的complete binary tree max sum of 2 nodes 题
: 当场 40min white board 给出了O(N2) 的解法,对方表示赞许,但是没时间optimize
: 了。直觉告诉我应该有NlogN的解法。大牛指点下。
: 具体如下:
: given one complete binary tree, with positive and identical values in all
: nodes.
: Find 2 nodes, such that:
: sum of their path nodes to root (identical nodes will count only once) are maximum.

c****p
发帖数: 6474
5
我猜DP可做?

optimize
maximum.

【在 d***d 的大作中提到】
: 一道大公司诡异的complete binary tree max sum of 2 nodes 题
: 当场 40min white board 给出了O(N2) 的解法,对方表示赞许,但是没时间optimize
: 了。直觉告诉我应该有NlogN的解法。大牛指点下。
: 具体如下:
: given one complete binary tree, with positive and identical values in all
: nodes.
: Find 2 nodes, such that:
: sum of their path nodes to root (identical nodes will count only once) are maximum.

d*******d
发帖数: 2050
6
recursive, O(n)
d***d
发帖数: 99
7
wow..... then i totally screwed this question.... :(
i*****e
发帖数: 63
8
The difference here is you should avoid adding duplicate values.
So, an additional hashmap is needed?

【在 s*****y 的大作中提到】
: looks the same as this one:
: look at 1337's code
: http://www.mitbbs.com/article_t/JobHunting/31898169.html

s*****y
发帖数: 897
9
一样得,你看清楚点题目还有下面的讨论。
1 (共1页)
进入JobHunting版参与讨论
相关主题
amazon first phone interview, rejected问道题,binary tree里有一个有indegree 2
How many different binary trees are possible with n nodes ?Lowest common ancestor of two nodes of Binary Tree
判断 bst 疑问onsite面试题一道
non recursive binary tree traversal in O(n) time and O(1) space判断树为binary search tree 有多少种解法
binary tree, sum of 2 nodes == given numberCareercup 4.9解释一下?
amazon一道面试题感觉leetcode的OJ有点太偏重DP了
问个amazon面试题这个题做的对吗?
full or complete binary tree的问题求教一道老题
相关话题的讨论汇总
话题: nodes话题: binary话题: sum话题: tree话题: complete