#C5593. Unique Pairs Sum
Unique Pairs Sum
Unique Pairs Sum
Given an array of integers and a target integer ( k ), your task is to count the number of unique pairs ( (i, j) ) (with ( i < j )) such that ( nums[i] + nums[j] = k ). A pair is considered unique if the sorted order of the two numbers has not appeared before.
In each test case, you will first be given two integers, ( N ) and ( k ), where ( N ) denotes the size of the array. The next line contains ( N ) integers representing the array elements.
inputFormat
Input is read from standard input (stdin). The first line contains an integer ( T ) representing the number of test cases. For each test case, the first line contains two integers ( N ) and ( k ). The second line contains ( N ) space-separated integers denoting the elements of the array.
outputFormat
For each test case, output a single integer on a new line representing the number of unique pairs whose sum is equal to ( k ). The output should be written to standard output (stdout).## sample
3
4 5
1 2 3 4
5 6
3 1 4 1 5
3 0
-1 1 0
2
1
1
</p>