Container With Most Water
来源:互联网 发布:javagui编程代码 编辑:程序博客网 时间:2024/05/01 21:39
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.
public class Solution { public int maxArea(int[] height) { int max = 0; int i = 0; int j = height.length - 1; while (i < j) { if (max < min(height[i], height[j]) * (j - i)) { max = min(height[i], height[j]) * (j - i); } if (height[i] < height[j]) { i++; } else { j--; } } return max; } int min(int a, int b) { if (a < b) return a; return b; }}
- 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
- 見積もりがブレるメカニズム--標準技法には落とし穴がある 穴をふさぐ現場ルールを作ろう
- 解决SQL Server 2008提示评估期已过
- Java使用DOM读写XML
- jqury取元素CSS尺寸
- 解决SQL Server 2008安装时提示:重新启动计算机 失败
- Container With Most Water
- OpenFlow Wireshark Dissector on Mac OS
- SEのための提案力強化講座【第1回】 --なぜITエンジニアに提案力が必要なのか
- 技法の穴をふさぐ:規模編--技法のルールは分かりにくい数え方の“迷い”をなくす
- 终端发送邮件
- dm9000驱动理解四(dm9000操作函数集net_device_ops)
- 技法の穴をふさぐ:工数編 --技法の穴をふさぐ:工数編
- SEのための提案力強化講座【第2回】--提案のための基礎知識とスキル(上)
- 三星Exynos 4412 四核cortex A9 ARM Sate4412 核心板终于出来了!上图!!!