[leetcode 001] 两数之和
给定一个整数数组 nums
和一个目标值 target
,在该数组中找出和为目标值的两个整数,并返回他们的数组下标。
class Solution(object): def two_sum: """
:type nums: List[int]
:type target: int
:rtype: List[int]
""" n=len(nums) for x in range(n): for y in range(x+1,n): if nums[y] == target - nums[x]: return x, y