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.Th...
分类:
其他好文 时间:
2014-08-05 09:43:39
阅读次数:
191
题目: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....
分类:
编程语言 时间:
2014-08-05 05:17:28
阅读次数:
265
An example of in-order traversal application. My intuition is that, we have to serialize it into an array and check, but in-order traversal does exact...
分类:
其他好文 时间:
2014-08-05 03:03:48
阅读次数:
241
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4
5 6 7 0 1 2).
You are given a target value to search. If found in the array retur...
分类:
其他好文 时间:
2014-08-05 00:48:58
阅读次数:
248
基本上是标准的寻找前缀的问题,只需要insert和search函数就可以了。
我这里主要是修改一下n的记录方法,这里的n代表的不是叶子节点的标志,而是有多少单词经过了这条路径的标志。
然后是查找需要查找的前缀单词,如果没有找到,就返回0,表示没有单词以这个前缀单词为前缀,如果找到,直接返回n就是答案了。因为有n个单词经过了这条路径。
查找效率是常数。
使用静态分配空间的办法。
#...
分类:
其他好文 时间:
2014-08-04 21:40:28
阅读次数:
239
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.方法:为了使BST高度平衡,要找链表中的中值作为当前根节点。/** * Defin...
分类:
其他好文 时间:
2014-08-04 20:37:47
阅读次数:
194
分享下linux下编译安装memcached服务的步骤,一起来看看。系统:Ubuntu 13.10第一步:安装libevent-dev$aptitude search libevent-dev$aptitude install libevent-dev第二步:下载memcached并安装(www.j...
分类:
系统相关 时间:
2014-08-04 17:17:57
阅读次数:
358
oninput 是HTML5的标准事件,对于检测textarea, input:text, input:password 和 input:search 这几个元素通过用户界面发生的内容变化非常有用,在内容修改后立即被触发,不像 onchange 事件需要失去焦点才触发。oninput事件在主流浏览器...
分类:
其他好文 时间:
2014-08-04 17:11:27
阅读次数:
256
1. 查看docker信息(version、info)
# 查看docker版本
$docker version
# 显示docker系统的信息
$docker info
2. 对image的操作(search、pull、images、rmi、history)
# 检索image
$docker search image_name
# 下载image
$docker pull ...
分类:
其他好文 时间:
2014-08-04 14:19:37
阅读次数:
224
题目: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 on....
分类:
编程语言 时间:
2014-08-04 13:57:17
阅读次数:
242