class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
rst = []
count = 0
for i in nums:
tmp = target - i
if tmp in nums[count+1:]:
return [nums.index(i), nums[count+1:].index(tmp)+count+1]
else:
count += 1
pass
Leetcode 1.两数之和
最新推荐文章于 2024-07-08 17:23:57 发布