# -*- coding: utf-8 -*- class Solution: #' twoSum #' #' Given an array of integers, return indices of the two #' numbers such that they add up to a specific target. #' #' @examples #' s = Solution() #' print(s.twoSum([2,7,11,15], 13)) def twoSum(self, nums, target): ''' nums type: List[int] target type: int return type: List[int] ''' seen = {} for i, v in enumerate(nums): remaining = target - v if remaining in seen: return [seen[remaining], i] seen[v] = i return []