EasyArray· 66% acceptance
#188

Two Sum 38

Easy

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

Example 1

Input: nums = [38,15,20,31,2,13,24,35,6,17,28,39,10,21,32,3,14,25,36,7,18,18], target = 33

Output: [1,20]

nums[1] + nums[20] = 33

Constraints

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

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

twoSum

← All practice problems