diff --git "a/0001.\344\270\244\346\225\260\344\271\213\345\222\214/0001-\344\270\244\346\225\260\344\271\213\345\222\214.py" "b/0001.\344\270\244\346\225\260\344\271\213\345\222\214/0001-\344\270\244\346\225\260\344\271\213\345\222\214.py" index 9442d88..8b92177 100644 --- "a/0001.\344\270\244\346\225\260\344\271\213\345\222\214/0001-\344\270\244\346\225\260\344\271\213\345\222\214.py" +++ "b/0001.\344\270\244\346\225\260\344\271\213\345\222\214/0001-\344\270\244\346\225\260\344\271\213\345\222\214.py" @@ -5,11 +5,8 @@ def twoSum(self, nums, target): :type target: int :rtype: List[int] """ - hashmap = {} - for i, x in enumerate(nums): - if hashmap.has_key(target - x): - return [hashmap[target - x], i] - else: - hashmap[x] = i - - return [] \ No newline at end of file + dic = {} + for i, num in enumerate(nums): + if target - num in dic: + return [dic[target - num], i] + dic[num] = i \ No newline at end of file