Python solution

  • 0
    def twoSum(self, nums, target):
            d = {}
            for idx, val in enumerate(nums):
                compl = target - val
                if compl in d:
                    return (d[compl], idx)
                d[val] = idx
            return None

    Would appreciate any feedback

Log in to reply

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