#C668. Unique Recommendations
Unique Recommendations
Unique Recommendations
You are given a list of recommended items which may contain duplicates. Your task is to remove duplicate entries while preserving the order of their first appearance. The input consists of multiple test cases. For each test case, you will be given a number of items followed by the list of items. Your program should output the de-duplicated list for each test case, with items separated by a single space.
The challenge tests your ability to handle array processing and maintaining order while filtering duplicates. Mathematically, for a list , the desired output is a list such that if appears earlier than in and , only the first occurrence is kept in .
inputFormat
The input is read from standard input (stdin) and has the following format:\n\nThe first line contains an integer representing the number of test cases.\nFor each test case, the first line contains an integer representing the number of recommended items. The following line contains space-separated strings.
outputFormat
For each test case, output a single line on standard output (stdout) containing the unique recommended items separated by a single space, in the order of their first occurrence.## sample
3
5
apple banana apple orange banana
4
toy truck game toy
6
chair table chair lamp table chair
apple banana orange
toy truck game
chair table lamp
</p>