Two Sum 两数==target 方法二更好 题1,对时间复杂度有要求O(n),所以维护一个字典,遍历过的数值放在字典中,直接遍历时候查找字典中有没有出现差,查找字典时间复杂度是O(1),所以O(n)*O(1) = O(n),满足要求. nums = [0, 1, 2, 7, 11, 15] target = 9 def chek(nums, target): dict1 = {} for i, ele in enumerate(nums): if (target-ele) in dict1…