Created
May 27, 2022 05:34
-
-
Save thekhairul/1d86120aec6dded1ab500aa19b9106b1 to your computer and use it in GitHub Desktop.
Leetcode 1: Two sum - python
This file contains 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
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