-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11.cpp
More file actions
executable file
·31 lines (31 loc) · 812 Bytes
/
11.cpp
File metadata and controls
executable file
·31 lines (31 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
int maxArea(vector<int>& height) {
int left = 0;
int right = height.size()-1;
int answer = min(height[left], height[right])*(right-left);
cout<<answer;
while (left < right){
if (height[left] > height[right]){
right--;
answer = max(answer, min(height[left], height[right])*(right-left));
}else{
left++;
answer = max(answer, min(height[left], height[right])*(right-left));
}
}
return answer;
}
};
int main(){
Solution solution;
vector<int> a;
a.push_back(1);
a.push_back(1);
cout<<solution.maxArea(a);
}