題目

解答

1
2
3
4
5
6
7
8
9
10
class Solution:
def twoSum(self, nums, target):
num = []
for i,n in enumerate(nums):
m = target - n
if m in num:
num.append(n)
return [num.index(m), i]
else:
num.append(n)