#K49322. Duplicate Stamps Finder
Duplicate Stamps Finder
Duplicate Stamps Finder
You are given several batches of stamps. Each batch is represented by an integer m followed by m stamp IDs. Some stamps may appear only once while others may be duplicated.
Your task is to identify all the duplicate stamp IDs in each batch. If a batch does not have any duplicates, print No duplicates
. Otherwise, print the duplicate stamp IDs separated by a single space. The order of stamp IDs should follow the order of their first occurrence in the batch.
Formally, for each batch we want to find all x such that:
\( \text{count}(x) > 1 \)
inputFormat
The input is given via stdin and consists of multiple batches.
- The first line contains an integer T denoting the number of batches.
- For each batch:
- The first line contains an integer m, the number of stamps in that batch.
- The next line contains m space-separated integers representing the stamp IDs.
outputFormat
For each batch, output a single line:
- If there are duplicate stamp IDs, print them separated by a single space in the order of their first occurrence.
- If there are no duplicates, print
No duplicates
.
The output should be written to stdout.
## sample1
5
1 2 3 4 5
No duplicates
</p>