#K51742. Detect Duplicate Postal Codes
Detect Duplicate Postal Codes
Detect Duplicate Postal Codes
You are given a list of postal codes. Your task is to detect and output all postal codes that appear more than once in the list. The duplicate postal codes must be printed in ascending order. If there are no duplicates, you should print an empty output.
Note: The input will be provided through standard input (stdin) and the output should be written to standard output (stdout).
Example: If the input is:
6 1234 5678 1234 6789 2345 6789
Then the output should be:
1234 6789
The problem can be formally described as finding all elements \(x\) in the list such that their frequency is at least 2, and then printing those elements sorted in ascending order.
inputFormat
The first line contains an integer \(n\) representing the number of postal codes. The second line contains \(n\) space-separated integers representing the postal codes.
outputFormat
Output a single line of space-separated integers which are the duplicate postal codes sorted in ascending order. If there are no duplicates, print an empty line.
## sample3
9876 5432 6781