All problems

Bagging's Majority Vote

easyPythonEnsembles & Regularization

Ardwick Mutual routes an incoming claim by asking a panel of models rather than one. Each model on the panel was trained on its own random resample of the same claim history, so they are near-copies that go wrong in different places — which is the whole point, since mistakes that do not line up can outvote each other. Every model hands back one route label for the claim, and the panel now has to settle on a single one.

Task: Print the route label the panel settles on.

Input

The first line holds one integer m, the number of models on the panel. The second line holds m route labels separated by single spaces, one per model, in panel order. A label contains no spaces.

Output

One line holding the label named by the most models. Every model carries exactly the same weight, whatever its position on the panel and however sure of itself it was. If two or more labels are named equally often, print whichever of those comes first alphabetically.

Example:

Input:
3
A A B

Output:
A

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…