From b4fff25e6f68327d67e1f55f9171061fc4597eef Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 18 Jan 2025 01:13:20 +0900 Subject: modified 1_array_hashing/two_sum.py --- 1_array_hashing/two_sum.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to '1_array_hashing') 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] -- cgit v1.2.3