题目: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). ...
分类:
其他好文 时间:
2015-01-29 17:48:28
阅读次数:
180
题目链接:Container With Most Water
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 ...
分类:
其他好文 时间:
2015-01-29 12:48:22
阅读次数:
226
#include #include //use recurrence way to find most biggest total using namespace std;int sum=0;void print_value(int a[][110],int N) //printf the numb...
分类:
其他好文 时间:
2015-01-29 12:24:11
阅读次数:
188
find the most comfortable roadTime Limit: 1000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4096Accepted Submiss...
分类:
其他好文 时间:
2015-01-29 12:14:58
阅读次数:
166
Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uDescriptionHiking in the mountains is seldom an easy task for most people, as it is ...
分类:
其他好文 时间:
2015-01-28 17:28:12
阅读次数:
173
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
注意
You may n...
分类:
其他好文 时间:
2015-01-28 14:47:27
阅读次数:
197
For ordering the bytes representing an object, there are two common conventions. Consider a w-bit integer having a bit representation [xw-1, xw-2, ... , x1, x0 ], where xw-1 is the most significant...
分类:
其他好文 时间:
2015-01-28 13:09:28
阅读次数:
169
原题地址最朴素的想法就是,枚举容器的左边界和右边界,总能找到解,不过时间复杂度是O(n^2)的。改进I:从左向右枚举左边界,在此基础上从右向左枚举右边界,一旦右边界高度>=左边界高度就可以停止枚举了,因为继续枚举下去找到的矩形肯定面积更小。比如下图,左边界在位置0,高度为height[0]=3,那么...
分类:
其他好文 时间:
2015-01-28 12:53:58
阅读次数:
131
Total Accepted: 1167
Total Submissions: 3961
Given a string, find the length of the longest substring T that contains at most 2 distinct characters.
For example,Given s = “eceba”,
T is...
分类:
其他好文 时间:
2015-01-28 06:15:59
阅读次数:
149
>>> map(int,'0')[0]>>> int('-1')-1>>> map(int, l[1])Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with....
分类:
其他好文 时间:
2015-01-28 06:08:44
阅读次数:
369