Merge pull request #2597 from stevenleon99/patch-1

Update 0018.四数之和.md
This commit is contained in:
程序员Carl 2024-07-14 16:09:58 +08:00 committed by GitHub
commit f26a95dbb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -262,6 +262,11 @@ class Solution {
for (int j = i + 1; j < nums.length; j++) {
// nums[i]+nums[j] > target 直接返回, 剪枝操作
if (nums[i]+nums[j] > 0 && nums[i]+nums[j] > target) {
return result;
}
if (j > i + 1 && nums[j - 1] == nums[j]) { // 对nums[j]去重
continue;
}