diff options
Diffstat (limited to '1_array_hashing')
| -rw-r--r-- | 1_array_hashing/two_sum.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/1_array_hashing/two_sum.py b/1_array_hashing/two_sum.py index 42ad48e..0a7cf1d 100644 --- a/1_array_hashing/two_sum.py +++ b/1_array_hashing/two_sum.py @@ -42,10 +42,10 @@ from typing import Dict, List class Solution: def hashmap(self, nums: List[int], target: int) -> List[int]: hm: Dict = {} - for i, index in enumerate(nums): - if target - index in hm: - return [hm[target - index], i] - hm[index] = i + for i, n in enumerate(nums): + if target - n in hm: + return [hm[target - n], i] + hm[n] = i return [-1, -1] |
