Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 969ad0f

Browse files
Update Solution.java
1 parent 55ff889 commit 969ad0f

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

‎Algorithms/Medium/11_Container With Most Water/Solution.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@ class Solution {
22
public int maxArea(int[] height) {
33
int i = 0;
44
int j = height.length - 1;
5-
65
int maxArea = Integer.MIN_VALUE;
76

8-
while(i < j) {
7+
while(i < j) {
98
int h = Math.min(height[i], height[j]);
109
int width = j - i;
11-
1210
maxArea = Math.max(maxArea, h*width);
1311

14-
if(height[i] > height[j]) {
12+
if(height[i] > height[j]) {
1513
j--;
1614
} else {
1715
i++;
1816
}
19-
2017
}
2118

2219
return maxArea;
23-
2420
}
25-
}
21+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /