Skip to content

Commit 4f47f39

Browse files
authored
Merge pull request #1 from gzc426/master
typing
2 parents 50b792b + 72f574a commit 4f47f39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+819
-113
lines changed

2018.11.15/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

2018.11.16/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

2018.11.17/1.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
12
2+
1

2018.11.18/1.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
11
2+
1

2018.11.19/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
11

2018.11.20/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

2018.11.21/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1

2018.11.22/1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```
2+
const int x=[]{
3+
std::ios::sync_with_stdio(false);
4+
std::cin.tie(nullptr);
5+
return 0;
6+
}();
7+
class Solution {
8+
const int inf = 0x3f3f3f;
9+
public:
10+
int maxArea(vector<int>& height) {
11+
int ans = -inf;
12+
int l = 0;
13+
int r = height.size() - 1;
14+
while(l < r){
15+
int w = r - l;
16+
int h = height[l] < height[r]? height[l]:height[r];
17+
int c =w * h;
18+
if(ans < c) ans = c;
19+
while(l < r && height[l] <= h ) l++;
20+
while(l < r && height[r] <= h ) r--;
21+
}
22+
return ans;
23+
24+
}
25+
};
26+
```

2018.11.25-leetcode11/MQQM.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//748ms
2+
/*
3+
题目:
4+
给定 n 个非负整数 a1,a2,...,an,每个数代表坐标中的一个点 (i, ai)。在坐标内画 n 条垂直线,垂直线 i 的两个端点分别为 (i, ai) 和 (i, 0)。
5+
找出其中的两条线,使得它们与 x 轴共同构成的容器可以容纳最多的水。
6+
7+
说明:你不能倾斜容器,且 n 的值至少为 2。
8+
*/
9+
class Solution {
10+
public:
11+
int maxArea(vector<int>& height) {
12+
int max_area=0;
13+
14+
for(int i=0; i<=height.size()-2; i++){
15+
for(int j=i+1; j<=height.size()-1; j++){
16+
int cur_area=(j-i)*min(height[i], height[j]);
17+
if(cur_area>max_area){
18+
max_area=cur_area;
19+
}
20+
}
21+
}
22+
23+
return max_area;
24+
}
25+
};

0 commit comments

Comments
 (0)