*LeetCode-Container With Most Water
来源:互联网 发布:vmware fusion 8 mac 编辑:程序博客网 时间:2024/04/29 17:27
读题就读了很久
解法很巧妙 两个指针在两端 向中心挪动 因为只要其中一个高 它下次就不用挪 挪另一个 因为挪了没有意义 过程中keep max area
public class Solution { public int maxArea(int[] height) { int i = 0; int j = height.length - 1; int area = 0; while ( i < j ){ area = Math.max( area, Math.min(height[i], height[j]) * (j-i) ); if ( height[i] > height[j] ) j --; else i ++; } return area; }}
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
- 浅谈HTTP中Get与Post的区别
- Android程序的时候就要设计到编写xml布局文件,这里就教你如何设置xml的自动补全。
- 要看清的不是别人,要先看清自己
- bootstrap 提示框插件 bootstrap-growl 和bootstrap-notify用法简介
- 读取txt文件中的值并用myBatis将对象插入到数据库中
- *LeetCode-Container With Most Water
- 求数组的区间和
- 360与酷派和解,增持奇酷比例升至75%
- c++ primer plus第十二章-动态内存和类、复制构造函数
- WPF--窗口之间的值传递
- 基于xmpp客户端与服务器的快速重连方法、终端和服务器
- 校园网络 120 (数组模拟+技巧)
- lintcode做题总结, Sept 18
- ORA-12737: Instant Client Light: unsupported server character set CHS16GBK