#C2209. Most Popular Item among Customer Preferences
Most Popular Item among Customer Preferences
Most Popular Item among Customer Preferences
You are given an integer \(n\) representing the number of customers. Each of the following \(n\) lines contains a string representing a customer's preferences (a sequence of characters). Your task is to determine the most popular item (i.e. character) among all the customers.
The popularity of an item is determined by its total frequency (i.e. number of occurrences) across all the preference strings. In case of a tie, output the lexicographically smallest item.
Note: Lexicographical order is the usual dictionary order. For example, among items with the same frequency, 'a'
is considered smaller than 'b'
.
inputFormat
The input is read from standard input and is structured as follows:
- The first line contains an integer \(n\) (the number of customers).
- The following \(n\) lines each contain a non-empty string representing a customer's preferences.
outputFormat
Output the most popular item (a single character) to standard output. If there is a tie, output the lexicographically smallest character among those with the highest frequency.
## sample4
abc
ab
aabb
cc
a