Container With Most Water
来源:互联网 发布:上海心动网络怎么样 编辑:程序博客网 时间:2024/06/01 09:12
class Solution {public: int maxArea(vector<int> &height) { int res=0; int head=0; int tail=height.size()-1; res=(tail-head)*(height[head]>height[tail]?height[tail]:height[head]); while(head<tail) { if(height[head]<height[tail]) { int tmp=height[head]; while((head<tail)&&(height[head]<=tmp)) { head++; } tmp=(tail-head)*(height[head]>height[tail]?height[tail]:height[head]); if(tmp>res) { res=tmp; } } else { int tmp=height[tail]; while((head<tail)&&(height[tail]<=tmp)) { tail--; } tmp=(tail-head)*(height[head]>height[tail]?height[tail]:height[head]); if(tmp>res) { res=tmp; } } } return res; }};
0 0
- 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
- YModem协议
- 用模板类封装OpenGL Shader Uniform 变量2
- 《李航:统计学习方法》笔记之感知机
- 在 Java 客户端中使用 SSL 身份验证
- Errors running builder 'javascript validator' on project
- Container With Most Water
- ios开发之倒计时实现的两种方法
- Web_PHP_PHP XML操作浅谈;
- Regular Expression Matching
- 根据单词中字符的位置,确定单词为句中第几个
- 给非计算机专业大二学生的建议
- JPA初识
- 关于data-ng-model和ng-model
- Palindrome Number