#C12188. Unique Numbers Finder
Unique Numbers Finder
Unique Numbers Finder
You are given an array of integers. Your task is to find and output the numbers that appear only once in the array. If there is no number that appears exactly once, output the message "No unique number found".
More formally, given an array \(A = [a_1, a_2, \dots, a_n]\), for each element \(a_i\), compute its frequency \(f(a_i)\) using the formula $$ f(a_i)=\text{number of times }a_i\text{ appears in }A. $$
Output all elements \(a_i\) such that \(f(a_i)=1\) in the order of their first occurrence. If none exist, output No unique number found
.
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 representing the elements of the array. Note that \(n\) can be zero.
outputFormat
If there exists at least one unique element, output them in a single line separated by a single space in the order they appear in the array. Otherwise, output the string No unique number found
.
8
4 -1 1 6 3 -1 3 3
4 1 6