Given an array of integers, every element
appears twice except for one. Find that single one.Note: Your algorithm should
have a linear runtime complex...
分类:
其他好文 时间:
2014-06-10 21:27:22
阅读次数:
284
Given an array of integers, every element
appears three times except for one. Find that single one.Note: Your algorithm
should have a linear runtime c...
分类:
其他好文 时间:
2014-06-10 20:42:48
阅读次数:
315
给定一个包含N个整数的数组,求数组的子数组之和的最大值。...
分类:
其他好文 时间:
2014-06-10 11:18:42
阅读次数:
154
java swing实现小球沿正弦曲线运动的代码 http://www.zuidaima.com/share/1852345677564928.htm...
分类:
编程语言 时间:
2014-06-10 10:58:28
阅读次数:
251
int removeDuplicates(int A[], int n) {
if(n <= 1)
return n;
int newIndex = 0;
for(int i = 1; i < n; ++i){
if(A[i] != A[newIndex])
A[++newIndex] ...
分类:
其他好文 时间:
2014-06-10 10:57:49
阅读次数:
131
A和B需要共享同一线程,同样的另一组A和B共享另一组线程,A和B相互之间不受影响。...
分类:
编程语言 时间:
2014-06-10 10:56:32
阅读次数:
232
问题:
给定的二叉查找树中,有两个节点不小心被调换了位置,现在需要将其修正,不改变树的结构。
分析:
二叉排序树的中序遍历是有序的,所以这个问题又是建立在中序遍历模板上的问题,所以我们可以对其进行中序遍历,并用一个pre指针指向当前遍历结果中的最后一个结点,即下次遍历前的前一个结点。然后就可以通过将当前结点与pre结点进行比较,来判断是否有序了。若乱序,就将这两个结点都放入到预先定义的容器中...
分类:
其他好文 时间:
2014-06-10 10:54:41
阅读次数:
153
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible...
分类:
其他好文 时间:
2014-06-10 10:52:42
阅读次数:
192
Write an algorithm to print all ways of arranging
eight queens on an 8*8 chess board so that none of them share the same row,
column or diagonal.思路:本质...
分类:
其他好文 时间:
2014-06-10 10:36:29
阅读次数:
182
问题:
给定一个有序链表,生成对应的平衡二叉搜索树。
分析
见Convert
Sorted Array to Binary Search Tree
实现:
TreeNode *buildTree(ListNode* head, ListNode *end){
if(head == NULL || head == end)
return NULL;
...
分类:
其他好文 时间:
2014-06-10 07:17:29
阅读次数:
264