Skip to content

Commit 8eb8da7

Browse files
author
Longerhaha
authored
Merge pull request #1 from Longerhaha/Longerhaha-patch-1
Update and rename 1.md to Be a fresh man.md
2 parents 8fa3e4e + 78ae774 commit 8eb8da7

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

2018.11.25-leetcode80/1.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
```cpp
2+
class Solution {
3+
public:
4+
//双下标一次遍历扫描
5+
int maxArea(vector<int>& height) {
6+
int height_len = height.size();
7+
int start = 0;
8+
int end = height_len - 1;
9+
int max_area = 0;
10+
while( start < end ){
11+
max_area = max(max_area, min(height[start], height[end]) * (end - start));
12+
//更新 start 和 end
13+
if(height[start] < height[end])
14+
start++;
15+
else end--;
16+
}
17+
return max_area;
18+
}
19+
};
20+
```

0 commit comments

Comments
 (0)