class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for i,item in enumerate(nums):
b=target-item
if b in nums:
j=nums.index(b)
if i!=j:
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for i,item in enumerate(nums):
b=target-item
if b in nums:
j=nums.index(b)
if i!=j:
return [i,j]
执行用时:1388 ms