A neighborhood cafe keeps a running ledger of every order it fills. Each ledger line simply records the loyalty-card number of whoever placed that order (a card can appear any number of times, once per order it placed). The owner wants to identify the single most loyal regular: the loyalty-card number that placed strictly more orders than any other card in the ledger. It is guaranteed the ledger has exactly one such card.
Line 1: one integer n -- the number of ledger lines (orders).
Next n lines: one integer cardId -- the loyalty-card number that placed that order.
Print a single integer: the loyalty-card number that placed the largest number of orders in the ledger.
1 <= n <= 100000 0 <= cardId <= 1000000000 Exactly one cardId achieves the maximum order count (no ties).
Example 1
Input
6 7 7 3 3 3 9
Expected
3
Explanation
Card 7 placed 2 orders, card 3 placed 3 orders, and card 9 placed 1 order. Card 3 has the strictly largest count, so the answer is 3.
Example 2
Input
1 42
Expected
42
Explanation
There is only one order in the ledger, placed by card 42, so it trivially has the largest count and the answer is 42.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →