标签:solution nbsp tor vector public 容器 else turn code
1 //双指针算法 2 class Solution 3 { 4 public: 5 int maxArea(vector<int>& height) 6 { 7 int n = height.size(); 8 int Area = 0; 9 int l = 0,r = n - 1; 10 while(l < r) 11 { 12 Area = max(Area,(r - l)*min(height[l],height[r])); 13 if(height[l] < height[r]) l++;//木板原理,谁小谁移动 14 else r--; 15 } 16 return Area; 17 } 18 };
标签:solution nbsp tor vector public 容器 else turn code
原文地址:https://www.cnblogs.com/yuhong1103/p/12499111.html