- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem167.py
More file actions
Latest commit
23 lines (19 loc) · 590 Bytes
/
Copy pathproblem167.py
File metadata and controls
23 lines (19 loc) · 590 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# <---coding: utf-8--->
# @Time: 2022/1/4/17:57
# @Author = posiondy
# @Email: 1547590574@qq.com
# @Software: PyCharm
fromtypingimportList
classSolution:
deftwoSum(self, numbers: List[int], target: int) ->List[int]:
left, right=0, len(numbers)-1
whileleft<right:
ifnumbers[right] +numbers[left] ==target:
return [left+1, right+1]
elifnumbers[right] +numbers[left] <target:
left+=1
else:
right-=1
return []
s=Solution()
print(s.twoSum([2,3,4],6))