LeetCode 11. Container With Most Water
来源:互联网 发布:linux telnet连接拒绝 编辑:程序博客网 时间:2024/06/05 19:38
描述
给出一些点,过点作垂线,找出两条线,使得与x轴围成的面积最大。
解决
遍历比较即可
class Solution {public: int maxArea(vector<int>& height) { int i = 0, j = height.size() - 1, maxVal = 0; int tmp; while (i != j){ maxVal = max(maxVal, min(height[i], height[j]) * (j - i)); height[i] < height[j] ? ++i : --j; } return maxVal; }};
0 0
- LeetCode 11. Container With Most Water
- [LeetCode]11.Container With Most Water
- LeetCode --- 11. Container With Most Water
- LeetCode 11.Container With Most Water
- [Leetcode] 11. Container With Most Water
- [leetcode] 11.Container With Most Water
- 【leetcode】11. Container With Most Water
- [LeetCode]11. Container With Most Water
- 11. Container With Most Water LeetCode
- leetcode 11. Container With Most Water
- leetcode 11.Container With Most Water
- [LeetCode OJ]11. Container With Most Water
- [leetcode] 11. Container With Most Water
- Leetcode 11. Container With Most Water
- leetcode 11.Container With Most Water
- leetcode 11. Container With Most Water
- LeetCode 11. Container With Most Water
- LeetCode *** 11. Container With Most Water
- Unity 控制摄像机跟随运动物体
- TOJ 2577.Rounders
- jQuery 之 (三)事件绑定、动画效果、封闭ajax、三级联动、插件
- 有关service
- 集群与分布式的区别
- LeetCode 11. Container With Most Water
- 单个参数在线调试
- Leetcode_19
- HttpUrlConnection和HttpClient
- 【读书笔记】《Effective Java》(3)-- 类和接口
- bzoj1033: [ZJOI2008]杀蚂蚁antbuster
- about wsgi
- 关于约瑟夫环的思考(三) c++
- Flask-sqlalchemy中的lazy的解释