added hashmap solution with fastest runtime
This commit is contained in:
parent
feb856028e
commit
10c4e5c6b0
@ -10,6 +10,14 @@ def twoSum(nums, target):
|
||||
#print(f'i is {nums[i]}, j is {nums[j]}')
|
||||
return [i,j]
|
||||
|
||||
#hashmap = {}
|
||||
|
||||
#for i in range(len(nums)):
|
||||
#complacement = target - nums[i]
|
||||
#if complacement in hashmap:
|
||||
# return [i, hashmap[complacement]]
|
||||
# else:
|
||||
#hashmap[nums[i]] = i
|
||||
|
||||
print(twoSum([2,7,11,15], 9))
|
||||
print(twoSum([3,2,4], 6))
|
||||
Loading…
Reference in New Issue
Block a user