#C11718. Find the Longest Time Genre
Find the Longest Time Genre
Find the Longest Time Genre
You are given a record of borrowed genres. Each genre is represented by a unique integer. Your task is to determine which genre has not been borrowed for the longest time. In other words, for each genre, record the last time it was borrowed and then select the genre whose last borrowing occurred the earliest.
Note: The input first contains an integer \(n\), representing the number of genres. The next line contains \(n\) space-separated integers, representing the sequence of borrowed genres in the order they were borrowed.
Example:
Input: 4 7 3 7 2</p>Output: 3
In the above example, the genre 3 was last borrowed at index 1 (0-indexed), which is earlier than genre 7 (last borrowed index 2) and genre 2 (index 3), so the answer is 3.
inputFormat
The first line of the input contains a single integer \(n\) (\(1 \le n\le 10^5\)), which represents the number of borrowing records. The second line contains \(n\) space-separated integers. Each integer represents the genre Bob borrowed in order.
outputFormat
Output a single integer denoting the genre which has not been borrowed for the longest time.
## sample4
7 3 7 2
3