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...
分类:
其他好文 时间:
2016-01-02 18:37:29
阅读次数:
173
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
\ ...
分类:
其他好文 时间:
2015-12-31 17:33:24
阅读次数:
151
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.原题链接:https://oj.leetcode.com/problems/convert-sorted-...
分类:
其他好文 时间:
2015-12-29 21:15:54
阅读次数:
193
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 devis...
分类:
其他好文 时间:
2015-12-28 17:04:27
阅读次数:
102
问题描写叙述: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...
分类:
其他好文 时间:
2015-12-28 10:28:26
阅读次数:
140
题目描述:Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipe...
分类:
编程语言 时间:
2015-12-25 18:43:50
阅读次数:
140
Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target.Note:Given target value is a floating...
分类:
其他好文 时间:
2015-12-24 14:38:10
阅读次数:
174
Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the target.Note:Given target value is a floating...
分类:
其他好文 时间:
2015-12-24 10:30:24
阅读次数:
128
根据 arraylist 的size和level比较, 从而每层bst只放一个元素public class Solution { public List rightSideView(TreeNode root) { List res = new ArrayList(); ...
分类:
其他好文 时间:
2015-12-24 07:04:09
阅读次数:
190
public boolean checkBST(TreeNode root) { return isBST(root, Long.MIN_VALUE, Long.MAX_VALUE); } public boolean isBST(TreeNode root, lo...
分类:
编程语言 时间:
2015-12-22 21:25:25
阅读次数:
221