Skip to content

Commit 2ee1903

Browse files
committed
🎨 (solution): Fix Python ruff
Fix Python ruff
1 parent 100672b commit 2ee1903

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

solutions/15. 3Sum/Solution.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ def threeSum(self, nums: list[int]) -> list[list[int]]:
44
n = len(nums)
55
returnList = []
66
for i, i_num in enumerate(nums):
7-
if i and i_num == nums[i-1]:
7+
if i and i_num == nums[i - 1]:
88
continue
9-
l = i + 1
10-
r = n - 1
11-
while l < r:
12-
sum = i_num + nums[l] + nums[r]
9+
left = i + 1
10+
right = n - 1
11+
while left < right:
12+
sum = i_num + nums[left] + nums[right]
1313
if sum == 0:
14-
returnList.append([i_num, nums[l], nums[r]])
15-
while l < r and nums[l] == nums[l+1]:
16-
l += 1
17-
while l < r and nums[r] == nums[r-1]:
18-
r -= 1
19-
l += 1
20-
r -= 1
14+
returnList.append([i_num, nums[left], nums[right]])
15+
while left < right and nums[left] == nums[left + 1]:
16+
left += 1
17+
while left < right and nums[right] == nums[right - 1]:
18+
right -= 1
19+
left += 1
20+
right -= 1
2121
elif sum < 0:
22-
l += 1
22+
left += 1
2323
else:
24-
r -= 1
24+
right -= 1
2525
return returnList

0 commit comments

Comments
 (0)