My solution for leetcode #11.
class Solution {
public:
int maxArea(vector<int>& height) {
int left = 0;
int right = height.size() -1;
int maxx = 0;
int cur_area;
while(left<right){
cur_area = (right - left)*min(height.at(left),height.at(right));
if(height.at(left) < height.at(right)){
left ++;
}
else{
if(height.at(right) < height.at(left)){
right --;
}else{
left ++;
right --;
}
}
maxx = maxx>cur_area?maxx:cur_area;
}
return maxx;
}
};