class Solution(object):
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """

        d = dict()  # Dict[value, position]
        for i, val in enumerate(nums):
            need = target - val
            if need in d:
                return [d[need], i]
            d[val] = i
