TopCoder problem "ClassScores" used in SRM 258 (Division II Level One)

Problem Statement


A teacher has just finished grading the test papers for his class. To get an idea of how difficult the test was, he would now like to determine the most common score on the test. In statistics, this is called the "mode" of a set of data points. For instance, if the scores were {65, 70, 88, 70}, then the mode would be 70, since it appears twice while all others appear once.

Sometimes, in the case of a tie, the mode will be more than one number. For instance, if the scores were {88, 70, 65, 70, 88}, then the mode would be {70, 88}, since they both appear most frequently.

You are given a int[] scores. You are to return a int[] representing the mode of the set of scores. In the case of more than one number, they should be returned in increasing order.



Method signature:int[] findMode(int[] scores)
(be sure your method is public)


-scores will contain between 1 and 50 elements, inclusive.
-Each element of scores will be between 0 and 100, inclusive.


{65, 70, 88, 70}
Returns: {70 }
The first example from the problem statement.
{88, 70, 65, 70, 88}
Returns: {70, 88 }
The second example from the problem statement.
{92, 56, 14, 73, 22, 38, 93, 45, 55}
Returns: {14, 22, 38, 45, 55, 56, 73, 92, 93 }
With no duplicates, all of the elements are the most frequent (appearing once each).

Problem url:

Problem stats url:




PabloGilberto , lbackstrom , brett1479 , Olexiy

Problem categories:

Simple Math, Simple Search, Iteration