Created
October 14, 2018 00:48
-
-
Save zhangxiaomu01/f21aceb933ba21f47f58005095311505 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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