#K40882. Shortest Unique Sequence Length
Shortest Unique Sequence Length
Shortest Unique Sequence Length
You are given a sequence of integers. Your task is to reduce the sequence by performing an operation that eliminates duplicate elements. The operation is defined in such a way that after all possible reductions, the length of the sequence becomes equal to the number of distinct elements in the original sequence.
In other words, if the sequence is given as \(a_1, a_2, \ldots, a_n\), then the answer is given by the formula:
[ \text{result} = \left| {a_1, a_2, \ldots, a_n} \right| ]
You need to process multiple test cases.
inputFormat
The input is given in stdin and has the following format:
- An integer \(t\) in the first line, representing the number of test cases.
- For each test case:
- An integer \(n\) representing the length of the sequence.
- A line with \(n\) space-separated integers representing the sequence.
outputFormat
For each test case, print a single line containing one integer: the number of distinct elements in the corresponding sequence. The output should be sent to stdout.
## sample2
4
3 3 2 2
5
1 1 1 1 1
2
1
</p>