leetcode1
程序员文章站
2024-03-09 11:51:41
...
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
d = {}
for i,items in enumerate(nums):
tmp = target - items
for key,value in d.items():
if value == tmp:
return [key, i]
d[i] = items
return None
下一篇: LeetCode1:两数之和