My python3 solution

  • 0
    class Solution:
        def twoSum(self, nums, target):
            :type nums: List[int]
            :type target: int
            :rtype: List[int]
            helper = {}
            for index, item in enumerate(nums):
                if item in helper:
                    return [helper[item], index]
                    helper[target-item] = index

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.