Dodomeki
Sign in
← Challenges
‹›

1. Pair That Sums to Target

Easy

Given an array of integers nums and an integer alvo, return the indices of the two numbers whose sum is equal to alvo.

There is exactly one solution, and you may not use the same element twice. Return the indices in increasing order.

Example 1
Input: nums = [3, 8, 11, 5], alvo = 13
Output: [1, 3]
Explanation: nums[1] + nums[3] = 8 + 5 = 13.
Example 2
Input: nums = [4, 4], alvo = 8
Output: [0, 1]
Constraints
  • 2 <= nums.length <= 10^4
  • -10^9 <= nums[i], alvo <= 10^9
  • There is exactly one solution.
ArraysHash map
Caso 1
nums =
[3,8,11,5]
alvo =
13
Expected =
[1,3]
Caso 2
nums =
[4,4]
alvo =
8
Expected =
[0,1]

Run checks these 2 cases. Submit runs all 6, including hidden ones.