题目链接:Pairs完全就是Two Sum问题的变形!Two Sum问题是要求数组中和正好等于K的两个数,这个是求数组中两个数的差正好等于K的两个数。总结其实就是“骑驴找马”的问题:即当前遍历ar[i],那么只要看数组中是否存在ar[i]+K或者ar[i]-K就可以了,还是用HashMap在O(1)...
分类:
其他好文 时间:
2014-08-15 17:17:19
阅读次数:
123
1,创建字符串,有@都是对象。NSString *myString1 = @"My String One”;将一个utf8编码的字符串实例化成对象NSString *myString2 = [NSString stringWithUTF8String:"My String Two"];第三种写法NS...
分类:
其他好文 时间:
2014-08-15 14:25:48
阅读次数:
289
784 - Maze ExplorationA maze of rectangular rooms is represented on a two dimensional grid as illustrated in gure 1a.Each point of the grid is ...
分类:
其他好文 时间:
2014-08-15 14:24:48
阅读次数:
176
Numeros, The Artist, had two listsAandB, such that,Bwas a permutation ofA. Numeros was very proud of these lists. Unfortunately, while transporting th...
分类:
其他好文 时间:
2014-08-15 14:10:28
阅读次数:
236
Description
Tamim and Lina, two of the biggest mega minds of Bangladesh went to a far country. They ate, coded and wandered around, even in their holidays. They passed several months in this way. B...
分类:
其他好文 时间:
2014-08-15 12:51:18
阅读次数:
217
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, suc...
分类:
其他好文 时间:
2014-08-15 10:47:38
阅读次数:
255
~~~~
题意:给出两行数字序列,求上下匹配的最多组数是多少.
匹配规则:
1.匹配对的数字必须相同。
2.每个匹配必须有且只能有一个匹配与之相交叉,且相交叉的两组匹配数字必须不同。
3.一个数最多只能匹配一次。
最长公共子序列的改编,令f[i][j]表示第一个序列的前i个数字和第二个序列的前j个数字的匹配的最优值。
状态转移:f[i][j]=max(f[p-1][q-1]+2,...
分类:
其他好文 时间:
2014-08-15 09:31:17
阅读次数:
205
Description
In order to make their sons brave, Jiajia and Wind take them to a big cave. The cave has n rooms, and one-way corridors connecting some rooms. Each time, Wind choose two rooms x and y, an...
分类:
其他好文 时间:
2014-08-15 00:06:46
阅读次数:
331
Description
You are given circular array a0,?a1,?...,?an?-?1.
There are two types of operations with it:
inc(lf,?rg,?v) — this operation increases each element on the segment
[lf,?rg] (inclu...
分类:
其他好文 时间:
2014-08-15 00:01:56
阅读次数:
327
DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located...
分类:
其他好文 时间:
2014-08-14 23:39:56
阅读次数:
234