Skip to content

Commit 78ae774

Browse files
authored
Update and rename 1.md to Be a fresh man.md
添加双下标一遍扫描代码
1 parent 8fa3e4e commit 78ae774

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

2018.11.25-leetcode80/1.md

-1
This file was deleted.
+20
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)