Skip to content

Commit 8d76656

Browse files
authored
Merge pull request #556 from garima231/patch-1
Create 11._Container_With_Most_Water.cpp
2 parents 730779d + bf38e3c commit 8d76656

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int maxArea(vector<int>& height) {
4+
int ans = 0, i=0, j=height.size()-1;
5+
6+
while(i<j)
7+
{
8+
int x = min(height[i], height[j])*(j-i);
9+
ans = max(ans, x);
10+
if(height[i]<height[j])
11+
i++;
12+
else
13+
j--;
14+
}
15+
return ans;
16+
}
17+
};

0 commit comments

Comments
 (0)