Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:
其他好文 时间:
2015-05-22 09:22:05
阅读次数:
84
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].解题思...
分类:
其他好文 时间:
2015-05-22 09:20:44
阅读次数:
94
FlattenBinaryTreetoLinkedListTotalAccepted:46999TotalSubmissions:163018MySubmissionsQuestionSolutionGivenabinarytree,flattenittoalinkedlistin-place.Forexample,Given1
/25
/\346Theflattenedtreeshouldlooklike:1
2
3
4
5
6clicktoshowhints.分析:先..
分类:
其他好文 时间:
2015-05-22 01:57:56
阅读次数:
91
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 / \ ...
分类:
编程语言 时间:
2015-05-22 01:54:09
阅读次数:
189
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.解题思路:先中序遍历找到mistake,然后替换即可,JAVA实现如下:...
分类:
编程语言 时间:
2015-05-22 01:49:49
阅读次数:
111
Unique Binary Search TreesTotal Accepted:48675Total Submissions:134436My SubmissionsQuestionSolutionGivenn, how many structurally uniqueBST's(binary s...
分类:
其他好文 时间:
2015-05-22 00:24:09
阅读次数:
103
Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree. 1 class Solut...
分类:
其他好文 时间:
2015-05-22 00:16:38
阅读次数:
177
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...
分类:
其他好文 时间:
2015-05-22 00:04:22
阅读次数:
144
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 n...
分类:
编程语言 时间:
2015-05-21 22:32:43
阅读次数:
187
Root of AVL TreeAn AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at mos...
分类:
其他好文 时间:
2015-05-21 22:02:09
阅读次数:
159