Mergeksorted linked lists and return it as one
sorted list. Analyze and describe its
complexity.思路:合并k个有序链表为一个有序链表。我们可以用先合并两个链表的方法,然后逐个遍历链表数组,与上一个合并结束...
分类:
其他好文 时间:
2014-05-12 15:07:06
阅读次数:
305
题目链接题意:给出一个以数组形式表示的数, 求该数加1后的结果,同样以数组形式返回。附上代码: 1
class Solution { 2 public: 3 vector plusOne(vector &digits) { 4 unsigned int
len = digit...
分类:
其他好文 时间:
2014-05-12 12:49:34
阅读次数:
268
题意:有 n 个人,每个人有一个diaosi值a[i],如果第 i 个人排在第 k 位置,则他的愤怒值就为a[i]*(k-1);
过程中有一个黑屋子,可以把人暂时放到黑屋子里。
求总的愤怒值最小;
区间DP:对dp[i][j],我们考虑i到j的(j-i+1)个人,对于第i个人我们可以假设他在第k个位置,则前面就有k-1个人在他前面,j-k个人在他后面,所以dp[i][j]=m...
分类:
其他好文 时间:
2014-05-12 07:02:55
阅读次数:
275
题目描述N cities are connected by a network of M
one-way roads. It is known that these roads do not cross outside the cities. The
numeration of the cities...
分类:
其他好文 时间:
2014-05-12 01:13:06
阅读次数:
345
原题链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1424
逐渐找到做这种题的感觉了。 二分法。g[i][j]存储坐标(i, j)的值,s[i][j]存储的值为左上角为起始点(1,1),右下角为(i,
j)的矩形区域内所有值的和,那么...
分类:
其他好文 时间:
2014-05-10 22:55:11
阅读次数:
347
1、后台连接数据库,取到数据string sql =
".......................................";string one =
OracleHelperTools.ExecuteScalar(sql); //这里图省事用的oraclehelperstring fl...
分类:
Web程序 时间:
2014-05-10 06:15:07
阅读次数:
405
原题地址:http://www.cnblogs.com/x1957/p/3373994.html题意:Given
an array of integers, every element appearstwiceexcept for one. Find that single
one.要求:线性时间复...
分类:
编程语言 时间:
2014-05-10 05:22:27
阅读次数:
408
Pat1076代码
题目描述:
Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with foll...
分类:
其他好文 时间:
2014-05-10 04:50:24
阅读次数:
403
Problem DescriptionA tree is a well-known data
structure that is either empty (null, void, nothing) or is a set of one or more
nodes connected by dire...
分类:
其他好文 时间:
2014-05-10 03:18:52
阅读次数:
374
原题地址:http://oj.leetcode.com/problems/single-number-ii/题意:Given
an array of integers, every element appearsthreetimes except for one. Find that
single ...
分类:
编程语言 时间:
2014-05-10 03:01:41
阅读次数:
413