Pair Matching Registry

MediumAcc. 89.7%
+35 XP 15

Combinatorial Sums

Count every pair $(i, j)$ such that nums[i] + nums[j] === target.

The Assignment

Your function receives nums and target.

  1. Use nested loops i and j = i + 1.
  2. Count every match.
  3. Print the final count.

01EXAMPLE 1

Inputnums=[1, 1, 1, 1], target=2
Output6

Explanation: 4 elements, 6 possible pairs.

Constraints

  • Iterate through all pairs (i < j).
ArraysCounting
JavaScript
Loading...
1 Hidden

Input Arguments

nums[1,1,1,1]
target2

Expected Output

6

Click RUN to test your solution