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 floati ...
分类:
其他好文 时间:
2016-07-14 02:04:10
阅读次数:
184
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 floati ...
分类:
其他好文 时间:
2016-07-14 01:55:25
阅读次数:
134
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 floati ...
分类:
其他好文 时间:
2016-07-13 20:23:43
阅读次数:
114
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
编程语言 时间:
2016-07-13 11:52:59
阅读次数:
193
初看这道题想到O(n2) 的暴力dp 用f[i][0]表示取第i个点为最低点时的答案, f[i][1]为最高点,且f[i][0] = max( f[j][1] ) +1 这样每次都要查询前面区间满足 h[i]>h[j] 的最大值, 可以考虑 线段树区间查询 或者 BIT 或者BST , 时间降至O( ...
分类:
其他好文 时间:
2016-07-12 23:01:28
阅读次数:
210
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should ...
分类:
其他好文 时间:
2016-07-12 21:17:59
阅读次数:
173
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 ...
分类:
其他好文 时间:
2016-07-11 18:47:56
阅读次数:
141
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in ...
分类:
其他好文 时间:
2016-07-11 16:37:12
阅读次数:
195
This is a BST(binary search tree) numbers counting problem but solved in dynamic programing. https://discuss.leetcode.com/category/104/unique-binary-s ...
分类:
其他好文 时间:
2016-07-06 23:15:38
阅读次数:
157