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

Method twoSum

1-two-sum/two-sum.py:6–13  ·  view source on GitHub ↗
(self, nums: List[int], target: int)

Source from the content-addressed store, hash-verified

4
5class Solution:
6 def twoSum(self, nums: List[int], target: int) -> List[int]:
7 num_map = {}
8 for i, num in enumerate(nums):
9 complement = target - num
10 if complement in num_map:
11 return [num_map[complement], i]
12 num_map[num] = i
13 return []

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected