MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / twoSum

Method twoSum

-1-Two-Sum/two-sum.py:2–9  ·  view source on GitHub ↗
(self, nums, target: int)

Source from the content-addressed store, hash-verified

1class Solution:
2 def twoSum(self, nums, target: int):
3 visited = {}
4 for i in range(len(nums)):
5 difference = target - nums[i]
6 if difference in visited:
7 return [visited[difference], i]
8 else:
9 visited[nums[i]] = i

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected