Democratic Naming
InterviewTime limit1sMemory limit1024 MB
Given n city names of length m, build the county name by picking, for each position, the letter most cities have there, breaking ties alphabetically.
- Level
Easy2 of 10
- Topics
- Array, Hash map, Implementation
- Solved
- No attempts yet
Problem
The county was created on artificially made land off the coast, with the code name "Built Anew Peninsula County", but its final name still needs to be chosen. The cities in the county vote on the individual letters of the name.
All cities in the county have a name with exactly letters, so the county name also has exactly letters. Each city prefers its own name, so it votes that the th letter of the county name matches its own th letter. For each of the positions, the letter with the most votes is picked. If several letters tie, the one earliest in the English alphabet is picked.
Given the city names, determine the result of the vote for the county name.
Input
The first line has two integers and (, ), the number of cities and the number of letters in each city name.
Each of the next lines has a string of length , the name of a city. The names consist only of lowercase English letters (a-z).
Output
Output the name of the new county.