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.
- Use nested loops:
iandj. - If
nums[i] + nums[j] === target, printiandjseparately. - Exit on the first match.
01EXAMPLE 1
Input
nums=[2, 7, 11], target=9Output
0
1Explanation: 2 + 7 = 9.
Constraints
- Only one solution is guaranteed.
- Do not use the same element twice.
ArraysSearching
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
nums[2,7,11,15]
target9
Expected Output
0 1
Click RUN to test your solution