[leecode]1.两数之和

class Solution:
    def twoSum(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        # list_res = []
        for i in range(len(nums)):
            distance = target-nums[i]
            if distance == nums[i]:
                nums[i] = 0.1
            if distance in nums:
                j = nums.index(distance)
                list_res = [i,j]
                return list_res

 

你可能感兴趣的:(leecode)