Skip to content

Instantly share code, notes, and snippets.

@zhangxiaomu01
Created October 14, 2018 00:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhangxiaomu01/f21aceb933ba21f47f58005095311505 to your computer and use it in GitHub Desktop.
Save zhangxiaomu01/f21aceb933ba21f47f58005095311505 to your computer and use it in GitHub Desktop.
class Solution {
public:
int maxArea(vector<int>& height) {
int len = height.size();
int maxWater = 0;
for(int i = 0; i< len; i++){
for(int j = i+1; j< len; j++){
int lens_i = height[i]>height[j]? height[j] : height[i];
int width = j - i;
if(width * lens_i > maxWater)
maxWater = width * lens_i;
}
}
return maxWater;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment