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.
2 parents 0991129 + 9f55f90 commit e4733e2Copy full SHA for e4733e2
CPP/array-2d/Leetcode11-Container_With_Most_Water
@@ -0,0 +1,29 @@
1
+class Solution {
2
+public:
3
+ int maxArea(vector<int>& height)
4
+ {
5
+ int i=0, j=height.size()-1;
6
+ int Soln=0;
7
+
8
+ while(i<j)
9
10
+ if(height[i] < height[j])
11
12
+ Soln = max(Soln, (j-i)*height[i]);
13
+ i+=1;
14
+ }
15
+ else if(height[i] > height[j])
16
17
+ Soln = max(Soln, (j-i)*height[j]);
18
+ j-=1;
19
20
+ else
21
22
23
24
25
26
27
+ return Soln;
28
29
+};
0 commit comments