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
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is
a palindrome.
"race a car" is no...
分类:
其他好文 时间:
2014-06-10 18:36:29
阅读次数:
193
问题:
给定一个链表的头指针,以及一个整数k,要求将链表按每k个为一组,组内进行链表逆置。少于k个的部分不做处理。
分析:
个人觉得问题的重点是熟悉链表的就地逆置操作,就是头插法。其他的考察点如果还有的话,就的细心程度。
实现:
void reverseList(ListNode *&pre, ListNode *head)
{
ListNode *tail = NULL;
w...
分类:
其他好文 时间:
2014-06-10 17:25:45
阅读次数:
305
给定一个包含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