Given an unsorted integer array, find the first
missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1]
return 2.Your algorithm s...
分类:
其他好文 时间:
2014-06-13 20:25:38
阅读次数:
241
1.什么是算法?正确、确定、可行、有穷的过程。2.什么是好的算法?a.正确(语法正确,编译连接,正确处理任意合法输入)b.健壮(处理不合法输入)
c.可读 d.效率
分类:
其他好文 时间:
2014-06-13 15:56:48
阅读次数:
209
一. 算法描述
冒泡排序思想:依次比较相邻的数据,将小数据放在前,大数据放在后;即第一趟先比较第1个和第2个数,大数在后,小数在前,再比较第2个数与第3个数,大数在后,小数在前,以此类推则将最大的数"滚动"到最后一个位置;第二趟则将次大的数滚动到倒数第二个位置......第n-1(n为无序数据的个....
分类:
其他好文 时间:
2014-06-13 15:51:42
阅读次数:
207
Questions:Given an unsorted integer array, find
the first missing positive integer.For
example,Given[1,2,0]return3,and[3,4,-1,1]return2.Your algorithm...
分类:
其他好文 时间:
2014-06-13 13:16:42
阅读次数:
205
There are generally two methods to write DFS
algorithm, one is using recursion, another one is using stack. (reference from
Wiki Pedia)Pseudocode for ...
分类:
其他好文 时间:
2014-06-13 08:39:34
阅读次数:
218
Question:Say you have an array for which
theithelement is the price of a given stock on dayi.Design an algorithm to find
the maximum profit. You may c...
分类:
其他好文 时间:
2014-06-12 19:55:05
阅读次数:
292
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
题目:...
解题思路:
顺时针方向旋转数组90°。这个题也是个没啥意思的题,自己画画图,找找规律。就出来了。我举一个n=4的例子还说明下规律:
通过图可以看出A[0][0] = A[3][0],....。从这些中我们可以找到如下规律:
A[i][j] = A[n-1-j][i];
A[n-1-j][i] = A[n-1-i][n-1-j];
A[n-1-i][n-1-j] = A[j][n-1-i];
A[j][n-1-i] = A[i][j];(原来的A[i][j...
分类:
其他好文 时间:
2014-06-10 18:09:47
阅读次数:
281
问题:
给定一个链表的头指针,以及一个整数k,要求将链表按每k个为一组,组内进行链表逆置。少于k个的部分不做处理。
分析:
个人觉得问题的重点是熟悉链表的就地逆置操作,就是头插法。其他的考察点如果还有的话,就的细心程度。
实现:
void reverseList(ListNode *&pre, ListNode *head)
{
ListNode *tail = NULL;
w...
分类:
其他好文 时间:
2014-06-10 17:25:45
阅读次数:
305