The Pair Seeker

MediumAcc. 90.1%
+35 XP 15

Target Matching

Given an array and a target sum, find the indices of the two numbers that add up to that target.

The Assignment

Your function receives nums and target.

  1. Use nested loops: i and j.
  2. If nums[i] + nums[j] === target, print i and j separately.
  3. Exit on the first match.

01EXAMPLE 1

Inputnums=[2, 7, 11], target=9
Output0 1

Explanation: 2 + 7 = 9.

Constraints

  • Only one solution is guaranteed.
  • Do not use the same element twice.
ArraysSearching
JavaScript
Loading...
1 Hidden

Input Arguments

nums[2,7,11,15]
target9

Expected Output

0
1

Click RUN to test your solution