EasyArray· 62% acceptance
#167

Two Sum 17

Easy

Given `nums` and `target`, return indices of two distinct numbers that add up to `target`. Exactly one solution exists. Variant **#17**.

Example 1

Input: nums = [17,2,39,10,21,32,3,14,25,36,7,18,29,0,11,22,33,4,15,26,21], target = 23

Output: [1,4]

nums[1] + nums[4] = 23

Constraints

  • 2 <= nums.length <= 10^4
  • Each input has exactly one solution

Acceptance: 62% · Topics: array, hash-table

twoSum

← All practice problems