Leetcode 11. 盛最多水的容器-双指针
代码:
class Solution { public: int maxArea(vector<int>& height) { int L = 0,R = height.size()-1; int max_Area = 0; while(L<R) { int ans_area = min(height[L],height[R])*(R-L); max_Area = max(max_Area,ans_area); if(height[L]<height[R]) { L++; } else{ R--; } } return max_Area; } };
以大多数人努力程度之低,根本轮不到去拼天赋~