def twoSum(self, nums, target):
compliments = {}
length = len(nums)
for i, num in enumerate(nums):
compliment_of_num = target-num
if compliment_of_num in compliments:
return [nums.index(compliment_of_num),i]
compliments.update({num:compliment_of_num})
我认为它是O(n),但是我认为“如果compliment_of_num in compliments”行是O(n)而不是O(1),这会使整个程序的复杂度变为O(N ^ 2)>