由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个题,bt中找最大的bst
相关主题
一个题ways of increasing subsequence (转载)
请教LEETCODE讲解部分的LCA一道题的变种。。Distinct Subsequence
"简单的"linklist的问题Leetcode problems' difficulty
non recursive binary tree traversal in O(n) time and O(1) space用Java做leetcode应该尽量遵循OO风格吗?
有人同看Populating Next Right Pointers in Each Node II的recursive写法么?2D matrix peak
问个题求问两题思路
求推荐学习recursive 算法的资料从tree的post order traversal和pre,能否build这个tree?
one amazon interview problemGOOG phone interview question
相关话题的讨论汇总
话题: bst话题: space话题: 方法话题: 中找话题: largest
进入JobHunting版参与讨论
1 (共1页)
j**********3
发帖数: 3211
1
我用最直接的方法,把他们都存到数组里,然后从左到右扫一遍。。。找到顺序乱的。。
但这个方法space o(n)
有啥好主意?还想到了用俩pointer那个方法,但这个不知道是否可行。。。
g****o
发帖数: 547
2
啥意思?
存到数组里后找longest increasing subsequence?
s********l
发帖数: 998
3
最大bst是说个数最多吗?
我觉得不用extra space把~
从底向上 返回每个node下 最大bst的个数 要是
有新的最大值就更新max
这样应该可以把~
j**********3
发帖数: 3211
4
对的
我知道这个办法并不好

【在 g****o 的大作中提到】
: 啥意思?
: 存到数组里后找longest increasing subsequence?

j**********3
发帖数: 3211
5
好像可以哦。。
楼主说的第二个方法可以么?

【在 s********l 的大作中提到】
: 最大bst是说个数最多吗?
: 我觉得不用extra space把~
: 从底向上 返回每个node下 最大bst的个数 要是
: 有新的最大值就更新max
: 这样应该可以把~

i**********u
发帖数: 119
6
中序遍历 最长递增序列
j**********3
发帖数: 3211
7
其实不需要存,是吧?

【在 i**********u 的大作中提到】
: 中序遍历 最长递增序列
a***a
发帖数: 739
8
Time: O(n), Space: O(1)应该能作到.
with Poster-Order process, recursively call on the left/right children,
which returns:
1. The largest BST size in this branch
2. The largest BST size in this branch starting with the root
3. The value range [min, max] of the BST in (2)
Based on this information returned from left/right children, the current
root can easily figure out the things it needs to return itself.
h***k
发帖数: 161
9
recursion is never space O1, except tail recursion

【在 a***a 的大作中提到】
: Time: O(n), Space: O(1)应该能作到.
: with Poster-Order process, recursively call on the left/right children,
: which returns:
: 1. The largest BST size in this branch
: 2. The largest BST size in this branch starting with the root
: 3. The value range [min, max] of the BST in (2)
: Based on this information returned from left/right children, the current
: root can easily figure out the things it needs to return itself.

1 (共1页)
进入JobHunting版参与讨论
相关主题
GOOG phone interview question有人同看Populating Next Right Pointers in Each Node II的recursive写法么?
讨论个Binary search tree的题目问个题
这道题讨论过没有?求推荐学习recursive 算法的资料
找2个sorted array中的第K小的元素,有O(lgn)方法吗?one amazon interview problem
一个题ways of increasing subsequence (转载)
请教LEETCODE讲解部分的LCA一道题的变种。。Distinct Subsequence
"简单的"linklist的问题Leetcode problems' difficulty
non recursive binary tree traversal in O(n) time and O(1) space用Java做leetcode应该尽量遵循OO风格吗?
相关话题的讨论汇总
话题: bst话题: space话题: 方法话题: 中找话题: largest