https://leetcode.com/problems/two-sum/
Problem
Solution
class Solution():
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
h = {}
for i, num in enumerate(nums):
n = target - num
if n not in h:
h[num] = i
else:
return [h[n], i]
solution = Solution()
solution.twoSum([1,2,3,4], 7)