【 以下文字转载自 JobHunting 讨论区 】
发信人: HNM (如是我闻), 信区: JobHunting
标 题: 这个Binary Tree的题来看看
发信站: BBS 未名空间站 (Sun Dec 20 19:47:42 2009, 美东)
1. given a binary tree ,find the largest sub-tree which is a BST...(largest
mea
ns subtree having largest no of nodes in it)
我的理解是subtree就是说是一个子树,比如要到原来树的leaf,而不能把原来树的inter
nal nodes做leaf.也就是不能中间截一块,是这样的吗?
有什么好方法.我写的特别繁琐.if else 很多,用recursion.
2. 第二题说,design n stacks in an array of N. 这个我想愿意肯定不是让一个
stack分派固定的.感觉是要综合调配的,比如,如果array还有空,就不能说某个stack不
能加入了.我
想法是keep一个free l