Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.Hide TagsDepth-first SearchLinked List 这....
分类:
其他好文 时间:
2015-01-15 21:47:04
阅读次数:
171
问题描述:
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you...
分类:
其他好文 时间:
2015-01-15 20:18:55
阅读次数:
137
Binary Search Tree IteratorImplement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Callin...
分类:
其他好文 时间:
2015-01-15 15:48:15
阅读次数:
135
问题描述:
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'...
分类:
其他好文 时间:
2015-01-14 22:53:40
阅读次数:
179
Givenn, how many structurally uniqueBST's(binary search trees) that store values 1...n?For example,Givenn= 3, there are a total of 5 unique BST's 1 .....
分类:
其他好文 时间:
2015-01-14 22:37:54
阅读次数:
241
题目:
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.
Calling next() will return the next smallest number in the BST.
Note:...
分类:
编程语言 时间:
2015-01-14 18:01:28
阅读次数:
182
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.
For example:
Given the below binary tree and sum
...
分类:
其他好文 时间:
2015-01-14 16:58:45
阅读次数:
167
题目:
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 ...
分类:
编程语言 时间:
2015-01-14 16:58:27
阅读次数:
222
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
= 22,
5
/ ...
分类:
其他好文 时间:
2015-01-14 16:55:08
阅读次数:
202
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 example:
Given binary tree {3,9,20,#,#,15,7},
...
分类:
其他好文 时间:
2015-01-14 15:36:13
阅读次数:
127