摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2015-01-23 21:38 雄哼哼 阅读(150) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t... 阅读全文
posted @ 2015-01-23 19:59 雄哼哼 阅读(183) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.思路比较简单,就是每次以中位数为根节点,然后左边即左子树,右边是右子树,递归下去即可超时代码(不知道为啥)... 阅读全文
posted @ 2015-01-23 17:54 雄哼哼 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's. 1... 阅读全文
posted @ 2015-01-23 17:19 雄哼哼 阅读(259) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note... 阅读全文
posted @ 2015-01-23 16:05 雄哼哼 阅读(120) 评论(0) 推荐(0) 编辑