[NeetCode] Two Integer Sum
NeetCode synced attempts for Two Integer Sum.
Tags: algorithms, neetcode, python
Categories: NeetCode
- Problem
- Synced automatically from
devbattery/neetcode-submissions
Notes
Write your own notes here. This section is preserved across syncs.
Attempts
Attempt 1 ยท 2026-04-21 ยท Python
- Commit:
4e2a6a0 - Source:
Data Structures & Algorithms/two-integer-sum/submission-1.py
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
answer_dict = {} # {v: i} for index
for i, v in enumerate(nums):
diff = target - v
if diff in answer_dict:
return [answer_dict[diff], i]
answer_dict[v] = i
Leave a comment