#K45007. Unique Elements
Unique Elements
Unique Elements
You are given a sequence of integers. Your task is to remove all duplicate elements from the sequence, keeping only the first occurrence of each element. In other words, given an array \( a_1, a_2, \dots, a_N \), output the unique elements in the same order they first appear.
Example:
Input: 7 1 2 2 3 4 4 5 Output: 1 2 3 4 5
inputFormat
The input is given via stdin and consists of two lines:
- The first line contains a single integer \( N \) (\( 0 \leq N \leq 10^5 \)), representing the number of elements in the sequence.
- The second line contains \( N \) integers separated by spaces, representing the elements \( a_1, a_2, \dots, a_N \).
outputFormat
Print the unique elements separated by a single space, in the order they first appear in the input. Output should be sent to stdout.
## sample7
1 2 2 3 4 4 5
1 2 3 4 5