LeetCode Container With Most Water
来源:互联网 发布:手机二手市场淘宝网 编辑:程序博客网 时间:2024/05/17 05:12
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 endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water.
Note: You may not slant the container.
class Solution {public:int maxArea(vector<int> &height) {int n = height.size();if (n <= 1)return 0;int maxsum = 0;int i = 0, j = n - 1;while (i < j) {int mini = height[i] < height[j] ? height[i] : height[j];int temp = mini * (j - i);if (temp > maxsum)maxsum = temp;if (height[i] < height[j])i++;elsej--;}return maxsum;}};
0 0
- LeetCode: Container With Most Water
- [LeetCode]Container With Most Water
- LeetCode Container With Most Water
- LeetCode: Container With Most Water
- [Leetcode] Container With Most Water
- Leetcode: Container With Most Water
- [LeetCode] Container With Most Water
- LeetCode Container With Most Water
- [Leetcode] Container With Most Water
- [LeetCode]Container With Most Water
- LeetCode-Container With Most Water
- Container With Most Water leetcode
- LeetCode - Container With Most Water
- LeetCode: Container With Most Water
- Leetcode: Container With Most Water
- 【LeetCode】Container With Most Water
- Leetcode: Container With Most Water
- LeetCode:Container With Most Water
- 在 JNI 编程中避免内存泄漏
- Mysql中的Cascade,NO ACTION,Restrict,SET NULL
- poj 3646 The Dragon of Loowater!水!!
- as Button 的label和 Label 的text文字换行
- POJ-1006-Biorhythms
- LeetCode Container With Most Water
- mybatis使用---利用mybatis-generator自动生成mapper、model、mapper.xml
- Java线程的一些面试知识
- c/c++内存释放知识总结
- POJ—3253—Fence Repair—【贪心】【优先队列】
- 数据挖掘笔记-聚类-DBSCAN-文档聚类
- CF #262 (DIV2) C . Present (二分答案)
- spring security 权限验证
- mysql定时任务