#C9134. Most Frequent Packet Identifier
Most Frequent Packet Identifier
Most Frequent Packet Identifier
You are given a log of packet identifiers. Your task is to determine the packet identifier that occurs most frequently. Formally, given an integer \(N\) and a list of \(N\) integers \(a_1, a_2, \ldots, a_N\), find the identifier with the maximum frequency. If there are multiple identifiers with the same highest frequency, output the one that appears first in the list. If \(N = 0\), print None
.
Example:
Input: 7 1 2 1 2 3 1 3</p>Output: 1
In the above example, the identifier 1 appears 3 times while 2 and 3 appear fewer times. Use standard input and output.
inputFormat
The first line contains a single integer \(N\) denoting the number of packet identifiers.
The second line contains \(N\) space-separated integers representing the packet identifiers.
outputFormat
Output a single integer which is the most frequent packet identifier. If there are no packets (i.e. \(N = 0\)), print None
.
7
1 2 1 2 3 1 3
1
</p>