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 265943e

Browse files
committed
Time: 202 ms (6.59%), Space: 59 MB (38.72%) - LeetHub
1 parent 857e016 commit 265943e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Solution {
2+
public:
3+
int maxArea(vector<int>& height) {
4+
5+
6+
int i=0,n=height.size(),j,ar=0,mx=0;
7+
j=n-1;
8+
9+
while(i<j)
10+
{
11+
ar=max(ar,(j-i)*min(height[j],height[i]));
12+
13+
if(height[i]<height[j])
14+
{
15+
i++;
16+
}
17+
else
18+
{
19+
j--;
20+
}
21+
22+
}
23+
return ar;
24+
25+
26+
}
27+
};

0 commit comments

Comments
(0)

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