Rare Number
InterviewTime limit2sMemory limit1024 MB
Given a list of N integers, print the value that occurs the fewest times, breaking ties by choosing the smallest value.
- Level
Easy3 of 10
- Topics
- Hash map, Array, Implementation
- Solved
- No attempts yet
Problem
An integer sequence A = (A1, A2, …, AN) of length N is given.
Print the integer that appears in A the fewest times. If more than one integer qualifies, print the smallest such integer.
Input
The input is given from standard input in the following format.
N
A1 A2 … AN
Output
Print the integer that appears in A the fewest times. If more than one integer qualifies, print the smallest such integer.
Constraints
1 ≦ N ≦ 100.1 ≦ Ai ≦ 2000(1 ≦ i ≦ N).- All input values are integers.