02-1. Reversing Linked List (25)时间限制400 ms内存限制65536 kB代码长度限制8000 B判题程序Standard作者CHEN, YueGiven a constant K and a singly linked list L, you are suppos...
分类:
其他好文 时间:
2015-02-16 20:58:02
阅读次数:
310
Python 多进程中使用pool,pool中指定每次运行几个进程,当其中一个进程结束完毕后,会加入新的进程
#!/usr/bin/env python
#coding: utf-8
import multiprocessing
import os,time,random
def Lee():
print "Run task Lee-%s" %(os.getpid()...
分类:
编程语言 时间:
2015-02-16 16:56:41
阅读次数:
168
标题:Sort List通过率:21.3%难度:中等Sort a linked list inO(nlogn) time using constant space complexity.本题就是一个排序的问题,但是是针对单向链表去处理,那么问题关键就是怎么去处理链表,时间复杂度为nlogn,所以可以...
分类:
其他好文 时间:
2015-02-16 11:41:43
阅读次数:
146
Sort a linked list in O(n log n) time using constant space complexity.
可以利用归并排序解决该问题。普通的归并排序算法时间复杂度为O(nlogn),空间复杂度为O(n),因为需要建立两个数组来存储原来数组的值,这两个数组的长度加起来恰好为原数组的长度。但是对于链表可以省去复制两个已经排好序的数组的操作,从而使空间复杂度...
分类:
其他好文 时间:
2015-02-15 23:08:39
阅读次数:
175
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2015-02-14 21:23:48
阅读次数:
246
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Sort List
Sort a linked list in O(n log n) time using constant space complexity.
// 归并排序法:在动手之前一直觉得空间复杂度为常量不太可能,因为原来使用归并时,都是 O(N)的,需要复制出相等的空间来进行赋值归并。对于链表,实际...
分类:
其他好文 时间:
2015-02-14 17:34:48
阅读次数:
166
以前在10g数据库上,如果遇到绑定窥探导致执行计划慢的情况,想要清除某条SQL的执行计划,让它硬解析,找了很久都没有找到直接操作share pool的方法(总不能alter system flush shared_pool),只能通过对表ddl使SQL硬解析。现在终于找到了,使用sys.dbms_shared_pool.purge,在11g下可以直接使用,但在10g上需要alter session...
分类:
数据库 时间:
2015-02-13 20:00:50
阅读次数:
221
1. By Default, const Objects Are Local to a File
默认情况下,const对象是本地的
这是《C++ primary 5th》里的原文
When a const object is initialized from a compile-time constant, such as in our
definition of bufSize...
分类:
编程语言 时间:
2015-02-13 16:33:37
阅读次数:
184
1 题目Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Rem...
分类:
其他好文 时间:
2015-02-12 22:35:46
阅读次数:
206
上一篇已经分析了rpool 的三个module , 以及简单的物理关系. 这次主要分析用户进程和 worker_pool 进程还有worker_pool_worker 进程之间的调用关系. 在开始之前, 必须先明确一点, 就是一个worker_pool_worker 进程只有在处理完一个用户进程的任...
分类:
其他好文 时间:
2015-02-12 19:49:10
阅读次数:
257