A linked list is given such that each node
contains an additional random pointer which could point to any node in the list
or null.Return a deep copy ...
分类:
其他好文 时间:
2014-05-15 21:00:06
阅读次数:
325
题意:给定两个代表数字的链表,每个节点里存放一个digit,数字是逆方向的,将这两个链表相加起来
思路:
1.i, j遍历l1,l2至最长,短的补零
2..设置一个进位变量c, 第i次遍历 l1,l2,c的和除以10进位,mod10留在这一位
3.出循环后还要检查是不是还有进位
复杂度:O(m+n), 空间O(m+n)...
分类:
其他好文 时间:
2014-05-15 13:38:03
阅读次数:
258
这道题是我最初刷的那20多道之一,但一直没有过,被各种各样的情况折磨死了,直到把所有其他的题都写完,回来看大神对这道题是怎么处理的时候,才惊叹算法的奇妙。再次验证了我的想法,如果要处理各种各样的特殊情况,一定是算法本身有问题。
之前看过很多有关在两个排序数组中找中位数的解法,大多根据两个数组长度不同分了很多种情况,各种讨论。下面要介绍的方法并没有直接求中位数,而是把求中位数转换成了求两个数组合并...
分类:
其他好文 时间:
2014-05-15 12:21:05
阅读次数:
273
Two SumGiven an array of integers, find two
numbers such that they add up to a specific target number.The function twoSum
should return indices of the...
分类:
其他好文 时间:
2014-05-15 10:48:59
阅读次数:
322
memcached集群2013-04-26
13:56:37|分类:memcached|标签:集群memcached|举报|字号订阅集群架构方面的问题 memcached是怎么工作的?
Memcached的神奇来自两阶段哈希(two-stage hash)。Memcached就像一个巨大的、存储.....
分类:
其他好文 时间:
2014-05-15 10:04:33
阅读次数:
490
面向对象编程--句柄类与继承引言: C++中面向对象编程的一个颇具讽刺意味的地方是:不能使用对象支持面向对象编程,相反,必须使用指针或引用。void get_prices(Item_base object,
Item_base *pointer,
Item_base &reference)
{
//需要根据指针或引用实际所绑定...
分类:
编程语言 时间:
2014-05-15 08:19:33
阅读次数:
359
Perforce requires at least two executables: the
server (p4d), and at least one Perforce client program (such as p4 on UNIX, or
p4.exe on Windows).If y...
分类:
其他好文 时间:
2014-05-15 07:51:28
阅读次数:
276
题意:给定一组数和另一个数,在这组数中找两个数,使它们的和等于给定的数
思路1: --> 错,因为题目要求返回下标。
1.排序
2.两个下标,一个指向头,一个指向尾
3.如果下标指向的两个元素相加大于给定的数,尾下标减一
如果小于,头下标加一
思路2: hash
1.用hash存储每个数的下标
2.数组,看hash[target-num[i]]是否存在
复杂度:时间O(n), 空间O(n)...
分类:
其他好文 时间:
2014-05-15 01:28:13
阅读次数:
297
[ 问题: ]
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the ta...
分类:
其他好文 时间:
2014-05-15 00:04:39
阅读次数:
377
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-14 23:11:14
阅读次数:
398