24 lines
471 B
Java
24 lines
471 B
Java
/*
|
|
* @lc app=leetcode id=11 lang=java
|
|
*
|
|
* [11] Container With Most Water
|
|
*/
|
|
|
|
// @lc code=start
|
|
class Solution {
|
|
public int maxArea(int[] height) {
|
|
int l = 0, r = height.length -1, max = 0;
|
|
while(l < r) {
|
|
max = Math.max(max, (r-l)*Math.min(height[l], height[r]));
|
|
if(height[l] < height[r]) {
|
|
l++;
|
|
} else {
|
|
r--;
|
|
}
|
|
}
|
|
return max;
|
|
}
|
|
}
|
|
// @lc code=end
|
|
|