mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
17 lines
460 B
C++
17 lines
460 B
C++
class Solution{
|
|
public:
|
|
int maxArea(vector<int> &height){
|
|
int maxArea = 0;
|
|
int left = 0;
|
|
int right = height.size()-1;
|
|
while(left<right){
|
|
maxArea = max(maxArea, (right-left)*min(height[left], height[left]));
|
|
if(height[left]<height[right])
|
|
left++;
|
|
else
|
|
right--;;
|
|
}
|
|
return maxArea;
|
|
}
|
|
}
|