#C13864. Filter Unique Primes
Filter Unique Primes
Filter Unique Primes
Given a list of integers, your task is to extract the unique prime numbers from the list while preserving their original order. A prime number is defined as a number \(p\) such that \(p > 1\) and its only divisors are 1 and \(p\). For example, if the input list is [17, 23, 23, 4, 2, 5, 4, 29, 5, 17]
, the output should be [17, 23, 2, 5, 29]
.
inputFormat
The first line contains an integer (n) representing the number of elements in the list. The second line contains (n) space-separated integers.
outputFormat
Output the unique prime numbers from the list in the order of their first occurrence, separated by a single space. If there are no prime numbers, output an empty line.## sample
5
2 3 5 7 11
2 3 5 7 11