LeetCode------11. Container With Most Water
来源:互联网 发布:模拟核弹爆炸软件 编辑:程序博客网 时间:2024/06/08 01:11
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.
Subscribe to see which companies asked this question
Runtime Error Message:Line 6: java.lang.ArrayIndexOutOfBoundsException: 2
Last executed input:[1,1]
Input:[1,1]
Output:0
Expected:1
public class Solution { public int maxArea(int[] height) { int left=0,right=height.length-1; int area=0; while(left<right){ area=Math.max(area,Math.min(height[left],height[right])*(right-left)); if(height[left]>height[right]){ right--; } // area=Math.max(area,Math.min(height[left],height[right])*(right-left)); else{ left++; } } return area; }}
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
- C#之WinForm基础 图片查看器(在代码中指定查看文件夹与格式),利用listbox、picturebox
- VR测试视频源,双目立体视觉测试视频,大分辨率2880x1440-25fps
- Material Design之CollapsingToolbarLayout使用
- 设置字体
- 如何用视频编辑软件让彩色突出
- LeetCode------11. Container With Most Water
- [BZOJ4032] [HEOI2015] 最短不公共子串 - 后缀自动机,序列自动机,BFS
- Android 窗口管理服务WindowManagerService 简介
- python中tile()函数
- Codeforces Round #372 (Div. 1) A. Plus and Square Root 解题报告
- android SD卡浏览器
- 试题:基本算法题之【计算买股票的第n天每股股票值多少钱】
- 欢迎使用CSDN-markdown编辑器
- hdu--5878(hdu 5878 I Count Two Three (2016 ACM/ICPC Asia Regional Qingdao Online 1001))