Skip to content

Commit c6a4f17

Browse files
committed
2019,12,4
1 parent a92eb1e commit c6a4f17

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

1-两数之和.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class Solution:
2+
def twoSum(self, nums: List[int], target: int) -> List[int]:
3+
nums_dict = {}
4+
for i in range(len(nums)):
5+
if nums_dict.get(target - nums[i]) is not None:
6+
return [nums_dict[target - nums[i]], i]
7+
else:
8+
nums_dict[nums[i]] = i

0 commit comments

Comments
 (0)