forked from onlybooks/python-algorithm-interview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path68-3.py
More file actions
11 lines (9 loc) · 376 Bytes
/
68-3.py
File metadata and controls
11 lines (9 loc) · 376 Bytes
1
2
3
4
5
6
7
8
9
10
11
import bisect
from typing import List
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
for k, v in enumerate(numbers):
expected = target - v
i = bisect.bisect_left(numbers[k + 1:], expected)
if i < len(numbers[k + 1:]) and numbers[i + k + 1] == expected:
return k + 1, i + k + 2