Skip to content

Commit 304e5bf

Browse files
committed
I infact find this algor but I write it wrong I put the end = 1 :(
1 parent f353a71 commit 304e5bf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution:
2+
def twoSum(self, numbers, target):
3+
"""
4+
:type numbers: List[int]
5+
:type target: int
6+
:rtype: List[int]
7+
"""
8+
length = len(numbers)
9+
start, end = 0, length-1
10+
while True:
11+
if numbers[start] + numbers[end] == target:
12+
return [start + 1, end + 1]
13+
elif numbers[start] + numbers[end] > target:
14+
end -= 1
15+
else:
16+
start += 1

0 commit comments

Comments
 (0)