Skip to content

Commit 917ca1b

Browse files
authored
Merge pull request gzc426#233 from love15less/patch-1
Create 暮成雪.md
2 parents cec7725 + aca11a8 commit 917ca1b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

2018.11.26-leetcode11/暮成雪.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public int maxArea(int[] height) {
3+
if( height.length < 2 ){
4+
return 0;
5+
}
6+
//双指针,复杂度O(n),5ms 91%
7+
int max=0;
8+
int i=0;
9+
int j= height.length-1;
10+
while(i < j){
11+
int areaTmp= (j-i) * Math.min(height[i] , height[j]);
12+
Boolean flag = height[i] > height[j] ? true : false;
13+
if(max < areaTmp){
14+
max = areaTmp;
15+
}
16+
if(flag == true){
17+
j--;
18+
}else{
19+
i++;
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)