1. Two Sum
题目:
https://leetcode.com/problems/two-sum/
难度:
Easy
觉得异常聪明的AC解法
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
lookup = {}
for i, num in enumerate(nums):
if target - num in lookup:
return [lookup[target - num],i]
lookup[num] = i
return []