Skip to content

Commit bf38e3c

Browse files
authored
Create 11._Container_With_Most_Water.cpp
1 parent e18a609 commit bf38e3c

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)