Why not Python?This is not a problem in python world,Only 4 line code you need

  • 1
    def twoSum(self, nums, target):
    	m = {}
    	for i,num in enumerate(nums):
    		if target - num in m:return [m[target - num],i + 1]
    		m[num] = i + 1

  • 0

    a wonderful AC~ First I think it would be TLE, So, ahead to HashTable.

Log in to reply

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