Skip to content

Instantly share code, notes, and snippets.

@thekhairul
Created May 27, 2022 05:34
Show Gist options
  • Save thekhairul/1d86120aec6dded1ab500aa19b9106b1 to your computer and use it in GitHub Desktop.
Save thekhairul/1d86120aec6dded1ab500aa19b9106b1 to your computer and use it in GitHub Desktop.
Leetcode 1: Two sum - python
def twoSum(nums, target):
dict = {}
for i in range(len(nums)):
if ((target-nums[i]) in dict):
return [dict[target - nums[i]], i]
dict[nums[i]] = i
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment