两数之和
class Solution:
def twoSum(self,nums,target):
"""
:type nums:List[int]
:type target:int
:rtype:List[int]
"""
for i in range(len(nums)):
number=target-nums[i]
for j in range(i+1,len(nums)):
if nums[j]==number:
return [i,j]
a = Solution()
print(a.twoSum([1,2,3],4))
网友评论