#K7176. Count Common Unique Elements
Count Common Unique Elements
Count Common Unique Elements
You are given T test cases. For each test case, you are given two arrays of integers of the same length. Your task is to count the number of unique elements that appear in both arrays.
More formally, let \(A\) and \(B\) be two sets constructed from the arrays. You need to compute \(|A \cap B|\), which is the number of elements common to both sets.
Please note that even if an element appears multiple times in an array, it should be considered only once.
inputFormat
The input is given from standard input and has the following format:
T N a1 a2 ... aN b1 b2 ... bN ... (repeated for each test case)
Here, the first line contains an integer \(T\) denoting the number of test cases. For each test case:
- The first line contains an integer \(N\) – the number of elements in each of the two arrays.
- The second line contains \(N\) space-separated integers representing the first array.
- The third line contains \(N\) space-separated integers representing the second array.
outputFormat
For each test case, output a single line containing one integer – the count of unique elements present in both arrays. In other words, if the arrays are represented by sets \(A\) and \(B\), output \(|A \cap B|\).
## sample2
5
1 2 3 4 5
5 4 3 2 1
3
1 1 1
1 2 3
5
1
</p>