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.
- Use nested loops
iandj = i + 1. - Count every match.
- Print the final count.
01EXAMPLE 1
Input
nums=[1, 1, 1, 1], target=2Output
6Explanation: 4 elements, 6 possible pairs.
Constraints
- Iterate through all pairs (i < j).
ArraysCounting
JavaScriptSystem handles I/O — write your function only
Loading...
1 Hidden
Input Arguments
nums[1,1,1,1]
target2
Expected Output
6
Click RUN to test your solution