-
Notifications
You must be signed in to change notification settings - Fork 0
LC 1099 [E] Two Sum Less Than K
Code with Senpai edited this page May 2, 2022
·
1 revision
class Solution:
def twoSumLessThanK(self, A: List[int], K: int) -> int:
A = sorted(A)
i = 0
j = len(A) - 1
ans = -1
while i < j:
S = A[i] + A[j]
if S < K:
ans = max(ans, S)
i += 1
else:
j -= 1
return ans
footer