Skip to content

Commit 373a19b

Browse files
committed
day-6
1 parent db102fc commit 373a19b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

two-sum-ii-input-array-is-sorted.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def twoSum(self, numbers: List[int], target: int) -> List[int]:
3+
l = 0
4+
r = len(numbers)-1
5+
while(l<r):
6+
s = numbers[l] + numbers[r]
7+
if s == target:
8+
return l+1, r+1
9+
elif s > target:
10+
r -= 1
11+
else:
12+
l += 1

0 commit comments

Comments
 (0)