1.两数之和
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(0,len(nums)):
if target>=0:
if nums[i]<=target:
a = i
sub = nums[i]
nums[i] = target+32768
try:
b = nums.index(target-sub)
if a==b:
continue
else:
return [a,b]
except:
continue
else:
continue
else:
if nums[i]>=target:
a = i
sub = nums[i]
nums[i] = target+10
try:
b = nums.index(target-sub)
if a==b:
continue
else:
return [a,b]
except:
continue
else:
continue