#
# 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
#
#
# @param numbers int整型一维数组
# @param target int整型
# @return int整型一维数组
#
class Solution:
def twoSum(self , numbers: List[int], target: int) -> List[int]:
# write code here
n=len(numbers)
dic={}
for i,x in enumerate(numbers):
dic[x]=i
for i in range(n):
if target-numbers[i] in dic and i!=dic[target-numbers[i]]:
return [i+1,dic[target-numbers[i]]+1]


京公网安备 11010502036488号