1.
归并排序原理:有长度为n的子序列a[n],可以将其看做n个长度为1的子序列,将相邻子序列两两归并后子序列数量减少一半,再对子序列进行两两归并,数量又减少一般,重复直到得到一个长度为n的子序列2.
实现归并操作的代码如下:/*array[s…m]和array[m+1…t]均已各自有序,合并使得a...
分类:
其他好文 时间:
2014-05-10 00:28:40
阅读次数:
382
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 complete a...
分类:
其他好文 时间:
2014-05-10 00:24:49
阅读次数:
255
1.for循环语句:for loop_counter in [REVERSE]
lowest_number .. highest_numberloop {.statements.}end loop;示例:declare v_i
number(4) := 0;begin for v_i in 0...
分类:
其他好文 时间:
2014-05-10 00:19:58
阅读次数:
396
翻转链表绝对是终点项目,应该掌握的,这道题要求的是翻转一个区间内的节点,做法其实很相似,只不过要注意判定开始是头的特殊情况,这样head要更新的,还有就是要把翻转之后的尾部下一个节点保存好,要么链表就断掉了。一趟就可以,遇到节点直接翻转,最后把整个翻转的链表再翻转一次,就实现了。
class Solution {
public:
ListNode *reverseBetween(List...
分类:
其他好文 时间:
2014-05-09 15:05:06
阅读次数:
225
1 def quick_sort(a) 2 3 return a if a.size x}) : []
6 7 end 8 9 array = [72,6,57,88,60,42,83,73,42,48,85] 10 11 p quick_sort(array)
#=> [6...
分类:
其他好文 时间:
2014-05-09 13:43:49
阅读次数:
318
PHP
支持八种原始类型。四种标量类型:布尔型(boolean)整型(integer)浮点型(float)(浮点数,也作“double”)字符串(string)两种复合类型:数组(array)对象(object)最后是两种特殊类型:资源(resource)NULL为了确保代码的易读性,本手册还介绍了...
分类:
Web程序 时间:
2014-05-09 13:19:34
阅读次数:
388
Say you have an array for which theithelement
is the price of a given stock on dayi.If you were only permitted to complete at
most one transaction (ie...
分类:
其他好文 时间:
2014-05-09 13:13:02
阅读次数:
283
一、冒泡排序冒泡排序算是最基础的一种算法了,复杂度为O(N^2),其基本思想是:从最低端数据开始,两两相邻比较,如果反序则交换。代码如下:/*最基本的冒泡排序*/void
BubbleSort1 (int n, int *array) /*little > big*/{ int i, j...
分类:
其他好文 时间:
2014-05-09 13:02:57
阅读次数:
319
Given an array S of n integers, are there
elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the
array which gives the sum of ...
分类:
其他好文 时间:
2014-05-09 10:27:29
阅读次数:
449
原地归并。下面是AC代码: 1 public void merge(int A[], int m,
int B[], int n) { 2 3 int len = A.length; 4 //first copy m elements of A...
分类:
其他好文 时间:
2014-05-09 05:59:54
阅读次数:
297