思路: 贪婪。从两段开始,计算面积。每次走一步,若左端高低较低,从左端走;反之,从右端走。
分类:
其他好文 时间:
2014-09-09 10:39:38
阅读次数:
169
Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.
If you were only permitted to complete at most one transaction (ie,...
分类:
其他好文 时间:
2014-09-08 09:39:06
阅读次数:
312
public class Solution { public int maxArea(int[] height) { int len = height.length, low = 0, high = len - 1; int area = 0; whi...
分类:
其他好文 时间:
2014-09-07 23:40:15
阅读次数:
233
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 endpo...
分类:
其他好文 时间:
2014-09-07 18:28:25
阅读次数:
271
【原题】http://acm.hdu.edu.cn/showproblem.php?pid=1598【类型】最小生成树+枚举【题意】给定一张无向有权图和一些询问,每一个询问都是一对起/终点,对于每一个询问,要求找到一条路能从起点到达终点,并且得到该条路上所有边权值中最大边与最小边的差,使得这个差值达...
分类:
其他好文 时间:
2014-09-07 17:16:35
阅读次数:
204
Container With Most WaterTotal Accepted:15862Total Submissions:50802My SubmissionsGivennnon-negative integersa1,a2, ...,an, where each represents a po...
分类:
其他好文 时间:
2014-09-07 15:57:25
阅读次数:
184
题目如下:
Problem A
The Most Distant State
Input: standard input
Output: standard output
The 8-puzzle is a square tray inwhich eight square tiles are placed. The remaining ninth square is uncove...
分类:
其他好文 时间:
2014-09-07 13:35:55
阅读次数:
284
转载请注明出处:http://blog.csdn.net/lttreeFactorialTime Limit:1500MSMemory Limit:65536KTotal Submissions:13993Accepted:8678DescriptionThe most important part...
分类:
其他好文 时间:
2014-09-07 13:30:05
阅读次数:
221
Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (ie...
分类:
其他好文 时间:
2014-09-07 13:24:55
阅读次数:
229