PROBLEM LINKS
DIFFICULTY
EASY
EXPLANATION
This was supposed to be a problem that anyone who knows basic programming could solve and I'm glad that it's satisfied our expectations.
For the given constraints there were two easy approaches that one could use to solve this problem:
Approach 1:
The number of elements in the array bounded just by 100. For each element check how many other elements are equal to this one and hence find out what is the corresponding count. This would take time O(N2). Since N <= 100 here this solution would fit easily into the time limit.
Approach 2:
The range of elements is small - all elements are between 1 and 10000. One could create a frequency map for the array. I.e. create an array FREQ of size 10000 such that FREQ[x] gives the number of times the number x appears in the array. Initially all values in FREQ are zeros. When you start reading input and say you read a number x, you should add 1 to FREQ[x]. It takes O(N) time to build this array after initialization. When all input values have been scanned, one could make iteration at the FREQ array to find the smallest element with the largest count.
SETTER'S SOLUTION
Can be found here.
TESTER'S SOLUTION
Can be found here.