Mock CCC '18 Contest 5 J2 - Smallest Mode

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Given a list of N integers, compute the one that appears most frequently.

If multiple integers are tied for most frequent, return the smallest such one.

Constraints

1 \le N \le 10

1 \le a_i \le 10

Input Specification

The first line of the input consists of a single integer, N.

The next line contains N space-separated integers. a_i represents the ith integer in the list.

Output Specification

Output, on a single line, the smallest number that appears most frequently in the list.

Sample Input

4
1 1 2 2

Sample Output

1

Comments

There are no comments at the moment.