Leetcode 1. Two Sum
Nov 12, 2023
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
hashmap = {}
for index,value in enumerate(nums):
diff = target - value
if diff in hashmap:
return [hashmap[diff],index]
else:
hashmap[value] = index
from this problem, i learned how to use HashMap