#C12305. Find the First Non-Repeating Integer
Find the First Non-Repeating Integer
Find the First Non-Repeating Integer
You are given an array of integers. Your task is to identify and output the first non-repeating integer in the array. In other words, find the first integer that appears exactly once.
If no such integer exists (i.e. every integer repeats or the array is empty), output None
.
For example, given the array [4, 5, 1, 2, 0, 4, 5, 1, 2], the answer is 0 because it is the first integer that does not repeat within the array.
The problem requires you to use efficient methods to count occurrences. A typical approach uses a hash map (or dictionary) to store frequencies. The position of elements is important, so you must traverse the array in order.
You can express any mathematical notation in LaTeX. For example, the frequency function can be denoted as \(f(x)\).
inputFormat
The input is given from standard input (stdin) and follows the format below:
n num1 num2 num3 ... numN
Where the first line contains a non-negative integer \(n\) representing the number of integers in the array. The second line contains \(n\) integers separated by spaces.
outputFormat
Output a single line to standard output (stdout) representing the first non-repeating integer in the array. If there is no such integer, output None
.
9
4 5 1 2 0 4 5 1 2
0