Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def __init__(self):
- self.flag = True
- def two_sum(self, nums: List[int], target: int) -> List[int]:
- result = []
- ndx = {}
- for i in range(len(nums)):
- x = target - nums[i]
- n = ndx.get(x)
- if n != None:
- result = [n, i]
- break
- ndx[nums[i]] = i
- return result
Advertisement
Add Comment
Please, Sign In to add comment