Mergeksorted linked lists and return it as one
sorted list. Analyze and describe its
complexity.思路:合并k个有序链表为一个有序链表。我们可以用先合并两个链表的方法,然后逐个遍历链表数组,与上一个合并结束...
分类:
其他好文 时间:
2014-05-12 15:07:06
阅读次数:
305
**Why can I access private variables in the
copy constructor?** >The access modifiers work on **class level**, and not on
object level.That is, two ob...
分类:
编程语言 时间:
2014-05-12 15:06:06
阅读次数:
315
Suppose a sorted array is rotated at some pivot
unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are
given a target value t...
分类:
其他好文 时间:
2014-05-12 07:31:40
阅读次数:
332
class Solution {public: ListNode
*insertionSortList(ListNode *head) { if (head == NULL) return NULL; ListNode*
sorted_head = head; ...
分类:
其他好文 时间:
2014-05-10 20:39:14
阅读次数:
419
Divide two integers without using
multiplication, division and mod
operator.这道题要AC也不容易,许多基础概念不懂。最后看了答案,自己再做也很难AC。还是要记住一些关键点才行:1.
负数的补码等于反码+1.所以负数取绝对值就...
分类:
其他好文 时间:
2014-05-10 06:52:22
阅读次数:
380
Problem DescriptionThere are N villages, which
are numbered from 1 to N, and you should build some roads such that every two
villages can connect to e...
分类:
其他好文 时间:
2014-05-10 02:28:50
阅读次数:
374
There are two sorted arrays A and B of size m
and n respectively. Find the median of the two sorted arrays. The overall run
time complexity should be ...
分类:
其他好文 时间:
2014-05-09 23:26:18
阅读次数:
353
N-Queens IThen-queens puzzle is the problem of
placingnqueens on ann×nchessboard such that no two queens attack each
other.Given an integern, return a...
分类:
其他好文 时间:
2014-05-09 20:34:01
阅读次数:
335
是我算法不对,还是笔记本CPU太差?我优化了两次,还是花了三四个小时来得到结果。在输出上加1就是最终结果。The
sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.Find the sum of all the primes
below two mil...
分类:
其他好文 时间:
2014-05-09 16:20:08
阅读次数:
295
一点小错,两次过,基本思想是先比较头元素,哪个小就在哪个list的基础上插入,需要考虑两种不同的结束方式 1
/** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int
val; 5 *...
分类:
其他好文 时间:
2014-05-09 09:21:59
阅读次数:
273