在一个经过旋转后的有序数组中查找一个目标元素。
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...
分类:
其他好文 时间:
2014-06-20 13:06:31
阅读次数:
261
06-03 20:45:24.143: E/AndroidRuntime(1230): FATAL EXCEPTION: main
06-03 20:45:24.143: E/AndroidRuntime(1230): java.lang.IllegalArgumentException: pointerIndex out of range
06-03 20:45:24.143: E/Andr...
分类:
编程语言 时间:
2014-06-20 12:23:54
阅读次数:
563
题目
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
方法
数组是有序的,要求创建的二叉树尽量平衡,很容易想到对数组进行二分操作,左边的数组元素是左子树,右边的数组元素是右子树。进行递归操作就可以了。
TreeNode...
分类:
其他好文 时间:
2014-06-20 11:06:46
阅读次数:
257
【题目】
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
给定一个已排序的数组(不存在重复元素),将它转换成一棵平衡二叉搜索树。
【思路】
由于平衡二叉树要求左右子树的高度差绝对值相遇等于1,也就是说左右子树尽可能包含相同数目节点。
则使用二分法来解本题即可。...
分类:
其他好文 时间:
2014-06-20 11:03:31
阅读次数:
246
1、
??
Recover Binary Search Tree
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...
分类:
其他好文 时间:
2014-06-20 10:13:49
阅读次数:
243
题目
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
方法
和有序数组的思想基本一样,将链表进行二分。
TreeNode getBST(ListNode head, int len) {
i...
分类:
其他好文 时间:
2014-06-20 09:46:33
阅读次数:
267
PDF-Search-EngineTooDoc
PDFQueen在这上面基本上可以搜索到现有的开源项目的相关资料,比较最新的文档,不过蛋疼的是英文,耐心看!
分类:
Web程序 时间:
2014-06-12 00:30:11
阅读次数:
267
【题目】
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
【题意】
将一个有序链表转换成平衡二叉树
【思路】
思路跟Convert Sorted Array to Binary Search Tree完全一样...
分类:
其他好文 时间:
2014-06-07 16:20:05
阅读次数:
287
range用法
使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节。
这里记录一下:
>>>
range(1,5)
#代表从1到5(不包含5)
[1,
2,
3,
4]
>>>
range(1,5,2)
#代表从1到5,间隔2(不包含5)
[1,
3]
>...
分类:
编程语言 时间:
2014-06-07 12:09:21
阅读次数:
276
打开File Search对话框,选中正则表达式,在搜索文本框输入 /n文件名称输入
*.java在范围里选中Enclosing projects然后就可以统计出整个项目的代码行数。
分类:
系统相关 时间:
2014-06-07 06:16:41
阅读次数:
279