#C12851. Unique Elements Extraction
Unique Elements Extraction
Unique Elements Extraction
Given an array of integers, your task is to extract the unique elements and output them in the order they first appear. Do not use any built-in functions that directly perform this task.
More formally, if you are given an array \(A = [a_1, a_2, \dots, a_n]\), you need to produce another array \(B\) such that each element in \(B\) is unique and appears in the same order as in \(A\), i.e., \(B = [b_1, b_2, \dots, b_k]\) where each \(b_i\) is the first occurrence of that particular value in \(A\).
Example:
Input: 8 4 5 9 4 5 6 7 9 Output: 4 5 9 6 7
inputFormat
The first line of input contains an integer \(n\), representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output the unique elements of the array in a single line, separated by a space, in the order they appeared in the input.
## sample8
4 5 9 4 5 6 7 9
4 5 9 6 7