1. 两数之和 https://leetcode-cn.com/problems/two-sum/description/
class Solution:
def twoSum(self, nums, target):
dicts = {}
for k, v in enumerate(nums):
if target - v in dicts:
return [dicts.get(target-v), k]
dicts[v] = k
class Solution:
def twoSum(self, nums, target):
dicts = {}
for k, v in enumerate(nums):
if target - v in dicts:
return [dicts.get(target-v), k]
dicts[v] = k