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
Array.prototype.slice.call(document.links,0).forEach(function(link){link.onmousedown
= null})插件总失效 用这个对付下
分类:
其他好文 时间:
2014-05-10 00:15:19
阅读次数:
250
在UEditor一些版本中,如果粘贴Excell中的内容到编辑器,会粘贴不进去,打开控制台发现JS报错了。
在ueditor.all.js:3048行报如下错误:
Uncaught TypeMismatchError: Failed to execute 'removeAttributeNode' on 'Element': The node provided is invalid....
分类:
其他好文 时间:
2014-05-09 15:16:34
阅读次数:
290
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 amxnmatrix, if an element is 0, set its
entire row and column to 0. Do it in
place.这题还是很简单的,就是有点坑,遍历矩阵的时候,每遇到0的时候,我们不能立即将所在行和列置0,否则,到最后矩阵所有...
分类:
其他好文 时间:
2014-05-09 08:51:57
阅读次数:
253
原地归并。下面是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