Two Sum — Arrays & Hashing

Find two different positions in a list of integers whose values add up to a chosen target, and report where they are.

Arrays & Hashing · Easy

The problem

Given integers and a target, find the two different positions whose values add up to the target. Exactly one pair works.

What to return

Constraints

Example

Input
nums = [2, 7, 11, 15], target = 9
Output
[0, 1]

Solve it

More in Arrays & Hashing

All algorithm problems