mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
Leetcode day 2 and 3
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user