摘要: Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened ... 阅读全文
posted @ 2015-05-23 21:34 TonyLuis 阅读(138) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum ... 阅读全文
posted @ 2015-05-23 20:55 TonyLuis 阅读(447) 评论(0) 推荐(0)
摘要: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo... 阅读全文
posted @ 2015-05-23 20:03 TonyLuis 阅读(154) 评论(0) 推荐(0)
摘要: Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest le... 阅读全文
posted @ 2015-05-23 19:58 TonyLuis 阅读(161) 评论(0) 推荐(0)
摘要: Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth... 阅读全文
posted @ 2015-05-23 19:48 TonyLuis 阅读(751) 评论(0) 推荐(0)
摘要: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:同上题,JAVA实现如下: public TreeNode sor... 阅读全文
posted @ 2015-05-23 19:47 TonyLuis 阅读(206) 评论(0) 推荐(0)
摘要: Given an array where elements are sorted in ascending order, convert it to a height balanced BST.解题思路:首先要理解,什么叫做height balanced BST Java for LeetCode ... 阅读全文
posted @ 2015-05-23 19:42 TonyLuis 阅读(225) 评论(0) 推荐(0)
摘要: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root). For ... 阅读全文
posted @ 2015-05-23 18:19 TonyLuis 阅读(231) 评论(0) 推荐(0)
摘要: Construct Binary Tree from Inorder and Postorder TraversalTotal Accepted: 31041 Total Submissions: 115870Given inorder and postorder traversal of a tr... 阅读全文
posted @ 2015-05-23 18:16 TonyLuis 阅读(193) 评论(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.解题思路一:preorder[... 阅读全文
posted @ 2015-05-23 10:49 TonyLuis 阅读(184) 评论(0) 推荐(0)
摘要: Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest le... 阅读全文
posted @ 2015-05-23 09:37 TonyLuis 阅读(129) 评论(0) 推荐(0)
摘要: Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and ... 阅读全文
posted @ 2015-05-23 09:32 TonyLuis 阅读(184) 评论(0) 推荐(0)
摘要: Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3... 阅读全文
posted @ 2015-05-23 09:26 TonyLuis 阅读(1413) 评论(0) 推荐(0)