- C++
class Solution { public: int maxArea(vector<int>& height) { int begin = 0; int end = height.size() - 1; int res = 0; while(begin!=end){ int temp = min(height[begin], height[end]) * (end - begin); if(res<temp){res = temp;} if(height[begin]>height[end]){end--;} else{begin++;} } return res; } };