#C6393. Unique Elements in an Array
Unique Elements in an Array
Unique Elements in an Array
You are given an array of integers. Your task is to find all the elements that appear exactly once in the array and then print them in ascending order.
The problem guarantees that the array will have at least 4 elements and the numbers can be both positive and negative. If no unique elements exist, output an empty line.
Note: An element is considered unique if its frequency in the array is exactly one.
Mathematical formulation:
Let \( A = [a_1, a_2, \dots, a_n] \) be the given array. Define the frequency function \( f(x) \) as the number of times \( x \) appears in \( A \). The task is to output the sorted sequence \( S \) defined as: \[ S = \{ x \in A \mid f(x) = 1 \} \]
inputFormat
The input consists of two lines:
- The first line contains a single integer \( n \) (\( n \geq 4 \)), representing the number of elements in the array.
- The second line contains \( n \) space-separated integers.
outputFormat
Print the unique elements in ascending order separated by a single space. If there are no unique elements, print an empty line.
## sample6
1 2 3 2 1 4
3 4
</p>