Mergeksorted linked lists and return it as one
sorted list. Analyze and describe its
complexity.思路:合并k个有序链表为一个有序链表。我们可以用先合并两个链表的方法,然后逐个遍历链表数组,与上一个合并结束...
分类:
其他好文 时间:
2014-05-12 15:07:06
阅读次数:
305
function fn1(){
//创建了一个数组
var fns = new Array();
//i这个变量是保存在fn1这个作用域中
for(var i=0;i
//数组中的值是一组函数
fns[i] = function(){
return i;
}
}
return fns;
}
var fs =...
分类:
Web程序 时间:
2014-05-12 14:37:20
阅读次数:
264
摘自:http://www.2cto.com/kf/201306/218838.html1、jQuery自带的$.map方式:$.map(json,
function (n) { return n; });这种方式原来用于复制数组还可以,今天用它复制数组中的某一条记录,发现字段名称丢失了,后来发现了...
分类:
Web程序 时间:
2014-05-12 13:30:24
阅读次数:
437
class Solution {public: int
maximalRectangle(vector > &matrix) { int rows = matrix.size(); if (rows
== 0) return 0; int cols =...
分类:
其他好文 时间:
2014-05-12 09:54:05
阅读次数:
250
<?php
function replace_url ($content) {
if (empty($content)) return;
//给URL地址加上 链接
$preg = '/(?:http:\/\/)?([\w.]+[\w\/]*\.[\w.]+[\w\/]*\??[\w=\&\+\%]*)/is';
$content = preg_replace($preg, '\1',...
分类:
其他好文 时间:
2014-05-12 07:17:12
阅读次数:
316
//求gcd(a, b)
LL gcd(LL a, LL b)
{
return b ? gcd(b, a%b) : a;
}
//求整数x和y,使得ax+by=d, 且|x|+|y|最小。其中d=gcd(a,b)
void gcd(LL a, LL b, LL& d, LL& x, LL& y)
{
if(!b)
{
d = a;
x = 1;
y = 0...
分类:
其他好文 时间:
2014-05-11 14:45:32
阅读次数:
240
Given two numbers represented as strings,
return multiplication of the numbers as a string.Note: The numbers can be
arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-05-11 14:35:13
阅读次数:
270
Search Insert Position
Total Accepted: 14091 Total
Submissions: 41005My Submissions
Given a sorted array and a target value, return the index if the target is found. If not, return the in...
分类:
其他好文 时间:
2014-05-11 05:53:03
阅读次数:
241
class Solution {public: ListNode
*insertionSortList(ListNode *head) { if (head == NULL) return NULL; ListNode*
sorted_head = head; ...
分类:
其他好文 时间:
2014-05-10 20:39:14
阅读次数:
419
坑爹地多次过,全都是写程序时不注意的小问题,书写习惯还需要进一步改善。遇到的bug有:忘记return语句;定义ListNode
runner = head.next,却将判断head==null的情况放在这句之后;
忘记了新的head将不会是原来的那个head,而是head.next;所以以后遇到...
分类:
其他好文 时间:
2014-05-10 06:59:37
阅读次数:
320