← Problem library

Arrays · Python

Two Sum

MediumArraysUnsolved

Problem

Return the indices of two distinct values in nums whose sum equals target.

Example input

nums = [2, 7, 11, 15], target = 9

Example output

[0, 1]

Constraints

2 <= len(nums) <= 10,000; exactly one answer exists

Python workspace

Reset code

Execution uses a timed child process in a temporary directory. It is development-only isolation, not a production sandbox.