└── 001_two_sum ├── README.md └── solution.py /001_two_sum/README.md: -------------------------------------------------------------------------------- 1 | https://leetcode.com/problems/two-sum/ -------------------------------------------------------------------------------- /001_two_sum/solution.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def twoSum(self, nums, target): 3 | """ 4 | :type nums: List[int] 5 | :type target: int 6 | :rtype: List[int] 7 | """ 8 | h = [] 9 | for i in range(len(nums)): 10 | m = target - nums[i] 11 | if m in h: 12 | return [nums.index(m), i] 13 | h.append(nums[i]) --------------------------------------------------------------------------------