CodeReview->Tree
文章平均质量分 81
amberFeb
这个作者很懒,什么都没留下…
展开
-
第55题 Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3原创 2015-05-02 18:46:04 · 406 阅读 · 0 评论 -
第54题 Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key.The原创 2015-05-02 17:13:48 · 290 阅读 · 0 评论 -
第56题 Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the followi原创 2015-05-02 21:37:34 · 313 阅读 · 0 评论 -
第六题 Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \原创 2014-10-06 05:55:37 · 317 阅读 · 0 评论 -
第70题 Populating Next Right Pointers in Each Node
Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its next right node. If t原创 2015-05-11 01:45:41 · 293 阅读 · 0 评论 -
第71题 Balanced Binary Tree
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 of the two subtrees of every node never differ原创 2015-05-11 02:05:06 · 336 阅读 · 0 评论 -
第72题 Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. Hide Tags Tree Array Depth-first Search原创 2015-05-11 03:14:35 · 349 阅读 · 0 评论 -
第57题 Sum Root to Leaf Numbers
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total原创 2015-05-03 00:11:34 · 309 阅读 · 0 评论 -
第78题 Binary Tree Level Order Traversal
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,9,20,#,#,15,7}, 3 / \ 9 20 /原创 2015-05-15 21:40:05 · 338 阅读 · 0 评论