2014年6月22日

leetcode - Validate Binary Search Tree

摘要: 题目:Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left sub... 阅读全文

posted @ 2014-06-22 20:03 laihaiteng 阅读(144) 评论(0) 推荐(0) 编辑

leetcode - Construct Binary Tree from Inorder and Postorder Traversal && Construct Binary Tree from Preorder and Inorder Traversal

摘要: 题目:Construct Binary Tree from Inorder and Postorder TraversalGiven inorder and postorder traversal of a tree, construct the binary tree.Note:You may a... 阅读全文

posted @ 2014-06-22 18:04 laihaiteng 阅读(177) 评论(0) 推荐(0) 编辑

leetcode - Binary Tree Zigzag Level Order Traversal

摘要: 题目:Binary Tree Zigzag Level Order TraversalGiven a binary tree, return thezigzag level ordertraversal of its nodes' values. (ie, from left to right, t... 阅读全文

posted @ 2014-06-22 11:51 laihaiteng 阅读(243) 评论(0) 推荐(0) 编辑

2014年6月21日

leetcode - Unique Binary Search Trees II

摘要: 题目:Unique Binary Search Trees IIGivenn, generate all structurally uniqueBST's(binary search trees) that store values 1...n.For example,Givenn= 3, your... 阅读全文

posted @ 2014-06-21 22:41 laihaiteng 阅读(153) 评论(0) 推荐(0) 编辑

leetcode - Convert Sorted List to Binary Search Tree

摘要: 题目:Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced B... 阅读全文

posted @ 2014-06-21 18:26 laihaiteng 阅读(253) 评论(0) 推荐(0) 编辑

2014年6月20日

leetcode - Flatten Binary Tree to Linked List

摘要: 题目:Flatten Binary Tree to Linked ListGiven a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 ... 阅读全文

posted @ 2014-06-20 14:01 laihaiteng 阅读(205) 评论(0) 推荐(0) 编辑

leetcode - Minimum Depth of Binary Tree

摘要: 题目:Minimum Depth of Binary TreeGiven a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the r... 阅读全文

posted @ 2014-06-20 11:25 laihaiteng 阅读(182) 评论(0) 推荐(0) 编辑

2014年6月19日

leetcode - Binary Tree Level Order Traversal i ii

摘要: 题目:Binary Tree Level Order Traversal i iii和ii的差别仅在于最后将结果逆序一下就行了,算法上基本相同个人思路:1、二叉树的层次遍历,我们一层一层地处理,用一个队列(A队列)将每一层的所有节点按照从左到右的顺序入队2、待该队列的所有节点都出队,并且用另外一个队... 阅读全文

posted @ 2014-06-19 19:48 laihaiteng 阅读(170) 评论(0) 推荐(0) 编辑

leetcode - Symmetric Tree

摘要: 题目:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmet... 阅读全文

posted @ 2014-06-19 13:59 laihaiteng 阅读(188) 评论(0) 推荐(0) 编辑

2014年6月18日

leetcode - Convert Sorted Array to Binary Search Tree

摘要: 题目:Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.个人思路:1、选... 阅读全文

posted @ 2014-06-18 22:44 laihaiteng 阅读(114) 评论(0) 推荐(0) 编辑

导航