MediumArray· 53% acceptance
#189

Two Sum 39

Medium

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

Example 1

Input: nums = [39,18,21,32,3,14,25,36,7,18,29,0,11,22,33,4,15,26,37,8,19,30,25], target = 43

Output: [0,15]

nums[0] + nums[15] = 43

Constraints

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

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

twoSum

← All practice problems