Skip to content

Commit 32cee11

Browse files
authored
Merge branch 'main' into main
2 parents 564febc + 9e8188d commit 32cee11

File tree

2 files changed

+23
-50
lines changed

2 files changed

+23
-50
lines changed

11. Container With Most Water.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <iostream>
2+
#include <vector>
3+
#include <algorithm>
4+
using namespace std;
5+
6+
class Solution {
7+
public:
8+
int maxArea(vector<int>& height) {
9+
int maxWater = 0;
10+
int lp = 0, rp = (int)height.size() - 1;
11+
while (lp < rp) {
12+
int width = rp - lp;
13+
int ht = min(height[lp], height[rp]);
14+
int currWater = width * ht;
15+
maxWater = max(maxWater, currWater);
16+
17+
// Move the pointer at the shorter line inward
18+
if (height[lp] < height[rp]) ++lp;
19+
else --rp;
20+
}
21+
return maxWater;
22+
}
23+
};

99.Maximize the Number of Target Nodes After Connecting Trees.cpp

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)