timed out completes 23/28 cases

This commit is contained in:
Jacob Delgado 2023-09-01 21:29:22 -07:00
parent c11cbf310c
commit 11f76be23e

View File

@ -0,0 +1,23 @@
def twoSum(numbers, target):
"""
:type numbers: List[int]
:type target: int
:rtype: List[int]
"""
last = len(numbers)-1
# print( last)
while last > 0:
if numbers[last] > target and target > 0:
for i in range(len(numbers)):
last -= 1
if numbers[last] < target:
break
for x in range(len(numbers)):
if numbers[x] + numbers[last] == target:
return [x+1, last+1]
last -= 1
print(twoSum([2,7,11,15], 9))
print(twoSum([-1,0], -1))
# print(twoSum([5,25,75], 100))