container with most water
2015-11-11 16:11
537 查看
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int maxArea(vector<int>&height)
{
int left = 0;
int right = height.size() - 1;
int result = 0;
while (left < right)
{
int area = min(height[left], height[right])*(right - left);
result = max(result, area);
if (height[left] < height[right])
++left;
else
--right;
}
return result;
}
#include<vector>
#include<algorithm>
using namespace std;
int maxArea(vector<int>&height)
{
int left = 0;
int right = height.size() - 1;
int result = 0;
while (left < right)
{
int area = min(height[left], height[right])*(right - left);
result = max(result, area);
if (height[left] < height[right])
++left;
else
--right;
}
return result;
}
相关文章推荐
- Rails -- empty、nil、blank三者之间的区别
- RAID 磁盘阵列 详解
- RAID技术详解
- 关于编译报错Task failed because "resgen.exe" was not found
- #Hostapd之main函数(2)
- 各个raid对比:性能和运行速度和读写方面
- PS 图像调整— — gain and bias
- 用NFS挂载root出现:NFS: failed to create MNT RPC client, status=-101(-110)
- Rails -- 时间的内置函数和格式说明
- Rails -- ActionController::InvalidAuthenticityToken解决办法
- pyhton基础之aiohttp
- Rails -- 中文字符串截取的函数
- Rails--自动清除开发日志
- Mplayer 1.2 源码分析--main函数
- golang中container/ring包用法
- Timus Online Judge 1651 Shortest Subchain
- No Brainer
- U3D 平行光阴影细节 Directional Shadow Details
- golang中container/heap包用法
- HDU 2389 ——Rain on your Parade——————【Hopcroft-Karp求最大匹配、sqrt(n)*e复杂度】