Skip to content

Commit 83f14be

Browse files
author
jinbeom
committed
Fix 3Sum Solution
1 parent 3d2514c commit 83f14be

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

3sum/kayden.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def threeSum(self, nums: List[int]) -> List[List[int]]:
1919
continue
2020
for j in range(i + 1, n):
2121
target = -(nums[i] + nums[j])
22-
if not check.get(target, None):
22+
if not check.get(target):
2323
continue
2424
if j >= check[target]:
2525
continue
@@ -47,6 +47,8 @@ def threeSum2(self, nums: List[int]) -> List[List[int]]:
4747
answer.add((nums[i], nums[l], nums[r]))
4848
l += 1
4949
r -= 1
50+
while nums[l] == nums[l - 1] and l < r:
51+
l += 1
5052

5153
if nums[l] + nums[r] < -nums[i]:
5254
l += 1

0 commit comments

Comments
 (0)