Skip to content

Commit 22bd48c

Browse files
committed
Sync LeetCode submission Runtime - 3 ms (46.65%), Memory - 17.8 MB (50.89%)
1 parent 4e210bc commit 22bd48c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
# Approach 2 - Two Pointers
1+
# Approach 2: Two Pointers
22

33
# Time: O(n log n)
44

55
class Solution:
66
def twoSumLessThanK(self, nums: List[int], k: int) -> int:
77
nums.sort()
8-
9-
result = -1
8+
answer = -1
109
left, right = 0, len(nums) - 1
11-
10+
1211
while left < right:
1312
total = nums[left] + nums[right]
1413
if total < k:
15-
result = max(result, total)
14+
answer = max(answer, total)
1615
left += 1
1716
else:
1817
right -= 1
19-
20-
return result
18+
19+
return answer
2120

0 commit comments

Comments
 (0)