I think the official documentation gives you
the answer to this one (albeit in a fairly nonspecific way):This method is the
dynamic equivalent of the ...
分类:
其他好文 时间:
2014-05-14 03:31:06
阅读次数:
223
You are given annxn2D matrix representing an
image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this
in-place?思路:先将矩阵转置,然后将第一列与最后...
分类:
其他好文 时间:
2014-05-14 03:09:35
阅读次数:
225
题意:有 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
Best Time to Buy and Sell StockSay you have an
array for which theithelement is the price of a given stock on dayi.If you were
only permitted to compl...
分类:
其他好文 时间:
2014-05-12 05:56:14
阅读次数:
315
题目链接:点击打开链接
题意比较明显,不赘述。
删除时可以把i-1转到根,把i+1转到根下
则i点就在 根右子树 的左子树,且只有i这一个 点
#include
#include
#include
#include
using namespace std;
#define N 300500
#define inf 10000000
#define L(x) tree[x].ch[0]
#d...
分类:
其他好文 时间:
2014-05-11 21:05:52
阅读次数:
365
题意:
给定2个操作
0、把区间的每个数sqrt
2、求和
因为每个数的sqrt次数很少,所以直接更新到底,用个标记表示是否更新完全(即区间内的数字只有0,1就不用再更新了)
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;
#define N 1000...
分类:
其他好文 时间:
2014-05-11 21:02:45
阅读次数:
325
Given a set ofnon-overlappingintervals, insert
a new interval into the intervals (merge if necessary).You may assume that the
intervals were initially...
分类:
其他好文 时间:
2014-05-11 16:35:35
阅读次数:
224
Given an array of words and a length L, format
the text such that each line has exactly L characters and is fully (left and
right) justified.You shoul...
分类:
其他好文 时间:
2014-05-11 15:15:29
阅读次数:
287
/* *******************************************
***** File Name: Love.c
***** Description: Love Story about you and me
***** Author: JPing.Cai
***** Date: 2014-5-10
***** Last Version: 1.0
* *******...
分类:
其他好文 时间:
2014-05-11 14:15:46
阅读次数:
290
前些天写了一篇《令人作呕的OpenSSL》,顿时引来了大量的恶评,令我非常尴尬,同时也觉得悲哀。如果说you can you up之类的,我觉得起码这人看出了我的本意,只是怀疑我的能力,但是我看到一些人竟然在我评价了一段僵尸代码后认定我不懂编译代码,这就悲哀了,这段代码大致如下:#if 0 /*abcdefghijklmn, ( and
ABCDEFGHHHHSASA
...
分类:
其他好文 时间:
2014-05-11 14:08:34
阅读次数:
238