Skip to content

Commit 3ade29e

Browse files
committed
萤火虫-N11
1 parent 92c7b10 commit 3ade29e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/main/java/N1_100/N11.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package N1_100;
2+
3+
/**
4+
* @author Yasin Shaw
5+
* @version v1.0
6+
*/
7+
public class N11 {
8+
public int maxArea(int[] height) {
9+
int maxArea = 0, l = 0, r = height.length - 1;
10+
while (l < r) {
11+
maxArea = Math.max(maxArea, Math.min(height[l], height[r]) * (r - l));
12+
if (height[l] < height[r]) {
13+
l++;
14+
} else {
15+
r--;
16+
}
17+
}
18+
return maxArea;
19+
}
20+
}

0 commit comments

Comments
 (0)