We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent db35ff3 commit bd00e38Copy full SHA for bd00e38
1.py
@@ -0,0 +1,16 @@
1
+# Runtime: 36 ms, faster than 99.74% of Python3 online submissions for Two Sum.
2
+# Difficulty: Easy
3
+
4
+class Solution:
5
+ def twoSum(self, nums, target):
6
+ """
7
+ :type nums: List[int]
8
+ :type target: int
9
+ :rtype: List[int]
10
11
+ stored_values = dict()
12
+ for index in range(len(nums)):
13
+ diff = target - nums[index]
14
+ if diff in stored_values:
15
+ return [stored_values[diff], index]
16
+ stored_values[nums[index]] = index
0 commit comments