We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ac76878 commit b692573Copy full SHA for b692573
container-with-most-water/TonyKim9401.java
@@ -0,0 +1,24 @@
1
+// TC:
2
+// SC:
3
+class Solution {
4
+ public int maxArea(int[] height) {
5
+ int max = 0;
6
+
7
+ int start = 0;
8
+ int end = height.length-1;
9
10
+ while (start < end) {
11
+ int heightLeft = height[start];
12
+ int heightRight = height[end];
13
14
+ int hei = Math.min(heightLeft, heightRight);
15
+ int wid = end - start;
16
17
+ max = Math.max(max, hei*wid);
18
19
+ if (heightRight > heightLeft) start += 1;
20
+ else end -= 1;
21
+ }
22
+ return max;
23
24
+}
0 commit comments