Skip to content

Instantly share code, notes, and snippets.

@mdpabel
Created June 25, 2023 16:06
Show Gist options
  • Save mdpabel/9ad85b7a1d21b8b6eaaff4bfcc66f1c7 to your computer and use it in GitHub Desktop.
Save mdpabel/9ad85b7a1d21b8b6eaaff4bfcc66f1c7 to your computer and use it in GitHub Desktop.
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