Skip to content

Commit 898e2a8

Browse files
committed
Sync LeetCode submission Runtime - 0 ms (100.00%), Memory - 18.6 MB (7.97%)
1 parent 44bbbd8 commit 898e2a8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

0001-two-sum/solution.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
class Solution:
77
def twoSum(self, nums: List[int], target: int) -> List[int]:
88
hashmap = dict() # value: index
9-
10-
for i in range(len(nums)):
11-
complement = target - nums[i]
9+
10+
for i, num in enumerate(nums):
11+
complement = target - num
1212
if complement in hashmap:
1313
return [i, hashmap[complement]]
14-
15-
hashmap[nums[i]] = i
14+
15+
hashmap[num] = i
16+
17+
return []
18+

0 commit comments

Comments
 (0)