From d38135b219e667f1638b9184b015043a87ed002a Mon Sep 17 00:00:00 2001 From: fang_chenfang <1217690899@qq.com> Date: Tue, 6 Aug 2024 10:36:18 +0800 Subject: [PATCH] =?UTF-8?q?Update=200018.=E5=9B=9B=E6=95=B0=E4=B9=8B?= =?UTF-8?q?=E5=92=8C.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Java版本第二个for循环内的剪枝操作直接return会漏解,应该是break --- problems/0018.四数之和.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problems/0018.四数之和.md b/problems/0018.四数之和.md index 8e34713d..f45dd939 100644 --- a/problems/0018.四数之和.md +++ b/problems/0018.四数之和.md @@ -264,7 +264,7 @@ class Solution { // nums[i]+nums[j] > target 直接返回, 剪枝操作 if (nums[i]+nums[j] > 0 && nums[i]+nums[j] > target) { - return result; + break; } if (j > i + 1 && nums[j - 1] == nums[j]) { // 对nums[j]去重