4-liner Python


  • 0
        def twoSum(self, nums, target):
            residual = {}
            for i, n in enumerate(nums):
                if n in residual: return [i, residual[n]]
                else: residual[target - n] = i
    

Log in to reply
 

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