Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- int maxArea(vector<int>& height) {
- int mxArea=0;
- int l=0;
- int r=height.size()-1;
- while(l<r)
- {
- mxArea = max(mxArea,(r-l)*min(height[r],height[l]));
- if(height[l]<height[r])
- {
- l++;
- }
- else
- {
- r--;
- }
- }
- return mxArea;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement