Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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