摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.class Solution... 阅读全文
posted @ 2014-07-02 21:45 OpenSoucre 阅读(248) 评论(0) 推荐(0) 编辑
摘要: Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.此题目有两种解决思路:1)递归... 阅读全文
posted @ 2014-07-02 21:23 OpenSoucre 阅读(172) 评论(0) 推荐(0) 编辑
摘要: Follow up for problem "Populating Next Right Pointers in Each Node".What if the given tree could be any binary tree? Would your previous solution stil... 阅读全文
posted @ 2014-07-02 20:53 OpenSoucre 阅读(189) 评论(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 @ 2014-07-02 20:00 OpenSoucre 阅读(205) 评论(0) 推荐(0) 编辑
摘要: Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to... 阅读全文
posted @ 2014-07-02 18:25 OpenSoucre 阅读(157) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t... 阅读全文
posted @ 2014-07-02 18:14 OpenSoucre 阅读(162) 评论(0) 推荐(0) 编辑
摘要: Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.int key[]={1000, 900, 500, 400, 100,90, 50, ... 阅读全文
posted @ 2014-07-02 17:54 OpenSoucre 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 给定一颗二叉树,和两个给定的结点,求出这两个结点之间的距离拿到题目时不要认为是求出二叉树的结点之间的最大距离,题目是求两个结点的之间的距离题目有几种情况两个结点分布在根节点的左子树或者右子树一个结点分布在根节点的左子树,一个结点分布在根节点的右子树这两个结点是兄弟结点一个结点是另外结点的祖先结点本题... 阅读全文
posted @ 2014-07-02 17:33 OpenSoucre 阅读(1596) 评论(0) 推荐(0) 编辑