Skip to content

Commit f26a95d

Browse files
Merge pull request youngyangyang04#2597 from stevenleon99/patch-1
Update 0018.四数之和.md
2 parents 8103625 + 718d3c0 commit f26a95d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

problems/0018.四数之和.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,11 @@ class Solution {
262262
263263
for (int j = i + 1; j < nums.length; j++) {
264264
265+
// nums[i]+nums[j] > target 直接返回, 剪枝操作
266+
if (nums[i]+nums[j] > 0 && nums[i]+nums[j] > target) {
267+
return result;
268+
}
269+
265270
if (j > i + 1 && nums[j - 1] == nums[j]) { // 对nums[j]去重
266271
continue;
267272
}

0 commit comments

Comments
 (0)