We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a7426ad commit f7540e3Copy full SHA for f7540e3
two-sum/doh6077.py
@@ -0,0 +1,8 @@
1
+class Solution:
2
+ def twoSum(self, nums: list[int], target: int) -> list[int]:
3
+ prevMap = {} # val : index
4
+ for i, n in enumerate(nums):
5
+ diff = target - n
6
+ if diff in prevMap:
7
+ return [prevMap[diff], i]
8
+ prevMap[n] = i
0 commit comments