diff --git a/solutions/11. Container With Most Water.md b/solutions/11. Container With Most Water.md index c8abcae..09d8721 100644 --- a/solutions/11. Container With Most Water.md +++ b/solutions/11. Container With Most Water.md @@ -17,8 +17,8 @@ public: while(left < right){ int h = min(height[left], height[right]); // 当前容器高度 res = max(res, h * (right - left)); - while(height[left] <= h) left++; // 跳过高度不够高的 - while(height[right] <= h) right--; + while(height[left] <= h && left < right) left++; // 跳过高度不够高的 + while(height[right] <= h && left < right) right--; } return res; }