Two Sum

Easy · Hashing · about 10 minutes

Asked at Google, Amazon, Meta, Apple, Microsoft, Samsung, Sony.

Exactly one pair of positions in nums holds values that add up to target. Find that pair and return its two indices [i, j] with i < j. A position can't be paired with itself.

Related guides