Sep 21, 2018

A Python Counter is a container that keeps track of how many times equivalent values are added. It can be used to implement the same algorithms for which bag or multiset data structures are commonly used in other languages.

Example:


from collections import Counter
n = input()
arr = Counter(map(int, raw_input().split()))
print arr.most_common(1)[0][0]