两数之和

class Solution:

    def twoSum(self, nums, target):

            hash_table = {}

            for i in range(len(nums)):

                if ((target-nums[i]) in hash_table.keys()):

                    return [hash_table.get(target-nums[i]),i]

                hash_table[nums[i]]=i

你可能感兴趣的:(两数之和)