Container With Most Water
来源:互联网 发布:阿里妈妈淘宝客采集器 编辑:程序博客网 时间:2024/05/09 23:30
类似于2Sum的思想,两边设一个指针,然后计算area,如果height[i] <= height[j],那么i++,因为在这里height[i]是瓶颈,j往里移只会减少面积,不会再增加area。
class Solution {public: int maxArea(vector<int> &height) { // Start typing your C/C++ solution below // DO NOT write int main() function int left=0,right=height.size()-1,maxA=0,area=0; while(left<right){ area=min(height[left],height[right])*(right-left); maxA=max(maxA,area); if(height[left]>=height[right]){ --right; }else{ ++left; } } return maxA; }};
- Container With Most Water
- Container with most water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- Container With Most Water
- MapReduce 实现k-means聚类
- javaSE 每天一点点之容器相关知识
- testlink报jiradbInterface错误,点击issue tracker management页面错误
- 线程同步:条件变量的使用细节分析
- 查看Oracle数据库表空间大小(空闲、已使用),是否要增加表空间的数据文件
- Container With Most Water
- 正则表达式基础知识
- ios iap设置
- java解压xx.tar.gz格式的压缩包(转)
- Web日志挖掘分析的方法
- 实习笔记之Spring MVC
- system2之:4-文件系统管理(上)
- tomcat+memcache 集群 memcached-session-manager配置
- Annotation