#K45652. First Unique Number
First Unique Number
First Unique Number
You are given a list of integers. Your task is to find the first unique integer in the list, i.e., the first number which appears exactly once. If there is no unique number in the list, output -1.
Note: An integer is considered unique if its frequency in the list is exactly 1. You may use efficient counting techniques such as hash maps. In mathematical terms, given a list \(a_1, a_2, \ldots, a_n\), find the smallest index \(i\) such that \(\#\{j : a_j = a_i\} = 1\). If no such index exists, return \(-1\).
inputFormat
The input consists of a single line of space-separated integers.
For example: 2 3 5 3 2 4 5
outputFormat
Output a single integer --- the first unique integer in the list or -1
if no unique integer exists.
2 3 5 3 2 4 5
4