Skip to content

Commit b0b0069

Browse files
authored
Add 011_containerwithmostwater (qiyuangong#13)
Add 011_containerwithmostwater Java solution by @arun-aditya
1 parent c820d54 commit b0b0069

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

java/011_containerwithmostwater.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public int maxArea(int[] height) {
3+
4+
int max=0;
5+
int left=0;
6+
int right=height.length-1;
7+
8+
while(left<right){
9+
max=Math.max(max, (right-left) * Math.min(height[left],height[right]));
10+
if(height[left]< height[right]){
11+
left++;
12+
}
13+
else{
14+
right--;
15+
}
16+
}
17+
18+
return max;
19+
}
20+
}

0 commit comments

Comments
 (0)