-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10.cpp
More file actions
42 lines (39 loc) · 864 Bytes
/
Copy path10.cpp
File metadata and controls
42 lines (39 loc) · 864 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
32
33
34
35
36
37
38
39
40
41
42
#include<bits/stdc++.h>
#include<String.h>
#include<iostream>
using namespace std;
int maxArea(vector<int> &h) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
int res=0;
int n = h.size();
int l=0,r=n-1;
while(l<r)
{
res=max(res,min(h[l],h[r])*(r-l));
if (h[l]<h[r])
{
int k=l;
while(k<r&&h[k]<=h[l])
k++;
l=k;
}
else
{
int k=r;
while(k>l&&h[k]<=h[r])
k--;
r=k;
}
}
return res;
}
int main()
{
// string s,p;
// cin>>s;
// cout<<"input p"<<endl;
// cin>>p;
// cout<<isMatch(s,p)<<endl;
// cout<<"hello";
}