摘要: Given a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, then right to left for the next level and al... 阅读全文
posted @ 2015-05-21 09:54 胡潇 阅读(153) 评论(0) 推荐(0) 编辑
摘要: Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.解题思路:给出一个二叉树的中... 阅读全文
posted @ 2015-05-21 06:02 胡潇 阅读(222) 评论(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.解题思路:给出一个二叉树的先序... 阅读全文
posted @ 2015-05-21 05:33 胡潇 阅读(201) 评论(0) 推荐(0) 编辑
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:用一个有序数组,创建一个平衡二叉查找树。为确保平衡,需要满足两子树的高度差不大于1,可以通过设置... 阅读全文
posted @ 2015-05-21 04:04 胡潇 阅读(172) 评论(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-05-21 03:36 胡潇 阅读(189) 评论(0) 推荐(0) 编辑