Skip to content

Commit 4000157

Browse files
authored
Create 11. Container With Most Water
1 parent 676c4f0 commit 4000157

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

11. Container With Most Water

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public:
3+
int maxArea(vector<int>& height) {
4+
5+
int final_area=0;
6+
int temp_area=0;
7+
8+
for(int i=0; i< height.size()-1; i++){
9+
for(int j = height.size()-1; j > i; j--){
10+
11+
if(height[i] < height[j]){
12+
temp_area = height[i] * (j-i);
13+
}
14+
else{
15+
temp_area = height[j] * (j-i);
16+
}
17+
18+
if(temp_area > final_area)
19+
20+
final_area=temp_area;
21+
}
22+
}
23+
return final_area;
24+
}
25+
};

0 commit comments

Comments
 (0)