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 262b903 commit 2e824d5Copy full SHA for 2e824d5
two-sum/jeongyunjae.py
@@ -3,9 +3,9 @@ class Solution:
3
def twoSum(self, nums: List[int], target: int) -> List[int]:
4
my_dict = {}
5
6
- for i in range(len(nums)):
7
- remaining = target - nums[i]
+ for i, data in enumerate(nums):
+ remaining = target - data
8
if remaining not in my_dict:
9
- my_dict[nums[i]] = i
+ my_dict[data] = i
10
else:
11
return [my_dict[remaining], i]
0 commit comments