快速排序也利用了分治的思想,跟归并排序排序相比减少了交换次数int partition(int
a[],int p,int r){ int x = a[r]; int i = p-1; int j; for(j = p;j<r;j++) {
if(a[j]...
分类:
其他好文 时间:
2014-05-26 02:47:46
阅读次数:
226
能举个例子吗?我也知道是括号里面取得值 但是哪个和哪个括号不清楚
还有是小括号中括号大括号也不清楚 能举个实例吗?$1,$2...是表示的小括号里的内容 $1是第一个小括号里的 ,$2是第2个小括号里的 比如
/gai([\w]+?)over([\d]+)/ 匹配 gainover123 $1= 括...
分类:
其他好文 时间:
2014-05-26 00:04:22
阅读次数:
282
select * from (select A.*,rownum rd from (select *
from [tablename] where [condition] order by [condition] ) A where
rownum=[startpage*pagesize];1.sel...
分类:
数据库 时间:
2014-05-25 22:29:33
阅读次数:
349
You are given two linked lists representing two non-negative numbers. The digits are
stored in reverse order and each of their nodes contain a single digit. Add the two numbers
and return i...
分类:
其他好文 时间:
2014-05-25 21:36:52
阅读次数:
268
我们在执行某些SQL语句的时候有可能会生成临时表.我们应该尽量的去避免临时表.因为临时表会浪费内存和时间.那么什么情况下会产生临时表呢?这是来自MYSQL官方的说明If
there is an ORDER BY clause and a different GROUP BY clause[官方说明]...
分类:
其他好文 时间:
2014-05-25 11:25:04
阅读次数:
199
寻找图中最小连通的路径,图如下:
算法步骤:
1. Sort all the edges in non-decreasing order of their weight.
2. Pick the smallest edge. Check if it forms a cycle with the spanning tree
formed so far. If cycle is n...
分类:
其他好文 时间:
2014-05-25 07:35:59
阅读次数:
301
【题目】
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.
For example,
Given n = 3,
You should return the following matrix:
[
[ 1, 2, 3 ],
[ 8, 9, 4 ],
[ 7, 6, 5 ]
]
【题意】
给定整数n, 将1,2,3...nxn个数按螺旋旋转的方式填入n...
分类:
其他好文 时间:
2014-05-25 07:08:17
阅读次数:
235
【题目】
The set [1,2,3,…,n] contains a total of n! unique permutations.
By listing and labeling all of the permutations in order,
We get the following sequence (ie, for n = 3):
"123"
"132"
"213"
"231"
"312"
"321"
Given n and k, return the kth permutation ...
分类:
其他好文 时间:
2014-05-25 06:13:37
阅读次数:
276
点击打开链接
题意:
集合S支持一下四种操作:
INSERT(S,x) : 如果S中没有x,则插入x
DELETE(S,x): 如果S中有x,则删除x
K-TH(S): 输出S中第K小的数
COUNT(S,x): 统计S中小于x的数有多少个
一共有Q(1 ≤ Q ≤ 200000)次操作。
Treap模板。。
#i...
分类:
其他好文 时间:
2014-05-24 18:03:11
阅读次数:
213
Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.
Return all possible palindrome partitioning of s.
For example, given s = "...
分类:
其他好文 时间:
2014-05-24 14:29:45
阅读次数:
222