Sponsored Reserved space — layout preview until AdSense is connected
easy +18 pts

Two Sum

Hash map in O(n).

Implement `two_sum(nums: list[int], target: int) -> tuple[int,int] | None`. Return the pair of indices or None.

Constraints

2 ≤ len(nums) ≤ 10^5

Example

>>> two_sum([2, 7, 11, 15], 9)
(0, 1)
18 points ~16 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Store value→index in a dict; check target-value on each element.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.
Sponsored Reserved space — layout preview until AdSense is connected