File tree Expand file tree Collapse file tree 1 file changed +14
-14
lines changed
Expand file tree Collapse file tree 1 file changed +14
-14
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments