Created
June 25, 2023 16:06
-
-
Save mdpabel/9ad85b7a1d21b8b6eaaff4bfcc66f1c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def twoSum(self, nums: List[int], target: int) -> List[int]: | |
seen = {} | |
for idx,num in enumerate(nums): | |
req = target - num | |
if req in seen: | |
return [seen[req], idx] | |
seen[num] = idx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment