#C2716. Most Frequent Flower
Most Frequent Flower
Most Frequent Flower
You are given a garden represented as a grid of characters. Each character represents a type of flower. Your task is to determine which flower appears most frequently in the entire garden. In case there is a tie (i.e. two or more flowers appear with the same maximum frequency), choose the flower that is lexicographically smallest.
Formally, let the garden be represented by an grid where each cell contains a lowercase letter. Find a character such that its total count is maximized. In case of a tie, output the smallest character in lexicographic order.
inputFormat
The first line contains two positive integers and ( possibly, depending on constraints) separated by a space, where is the number of rows and is the number of columns in the garden. This is followed by lines, each containing a string of exactly lowercase letters; each string represents one row of the garden.
outputFormat
Output a single character --- the type of flower that occurs most frequently in the garden. If there is a tie, output the lexicographically smallest flower among those with the maximum frequency.## sample
4 5
abbca
abcdef
ghiaj
kllmn
a