timed out completes 23/28 cases
This commit is contained in:
parent
c11cbf310c
commit
11f76be23e
23
NeetCodeRoadmap/Arrays_and_Hashing/167_Two_Sum_II.py
Normal file
23
NeetCodeRoadmap/Arrays_and_Hashing/167_Two_Sum_II.py
Normal 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))
|
||||
Loading…
Reference in New Issue
Block a user