From 17fdd4c39a37f2466eac3e1059f6485e0397371e Mon Sep 17 00:00:00 2001 From: ShusenTang Date: Sat, 18 Feb 2023 11:29:54 +0800 Subject: [PATCH] fix 11 --- solutions/11. Container With Most Water.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; }