MediumArray· 51% acceptance
#204

Two Sum 54

Medium

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

Example 1

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

Output: [0,5]

nums[0] + nums[5] = 43

Constraints

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

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

twoSum

← All practice problems