From 11b701fdb6ba689bdc9f07362e497a4d2ab5eefd Mon Sep 17 00:00:00 2001 From: AronJudge <2286381138@qq.com> Date: Mon, 4 Jul 2022 00:58:56 +0800 Subject: [PATCH] =?UTF-8?q?0018=20Java=E4=BB=A3=E7=A0=81=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=89=AA=E6=9E=9D=E6=93=8D=E4=BD=9C,?= =?UTF-8?q?=E4=B8=8D=E7=84=B6Leetcode=E4=B8=8D=E8=83=BD=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0018.四数之和.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/problems/0018.四数之和.md b/problems/0018.四数之和.md index 6cbd40c2..d0b7fc68 100644 --- a/problems/0018.四数之和.md +++ b/problems/0018.四数之和.md @@ -140,6 +140,11 @@ class Solution { for (int i = 0; i < nums.length; i++) { + // nums[i] > target 直接返回, 剪枝操作 + if (nums[i] > 0 && nums[i] > target) { + return result; + } + if (i > 0 && nums[i - 1] == nums[i]) { continue; }