#C408. Most Frequent Location
Most Frequent Location
Most Frequent Location
You are given a list of geographic coordinates in string format. Your task is to determine which location was visited most frequently. In case of a tie (where multiple coordinates have the same highest frequency), the coordinate that appears first in the list should be returned. If the list is empty, output an empty string.
Note: The input is provided via standard input (stdin) and the result should be output to standard output (stdout). The first line contains an integer n representing the number of coordinates. The following n lines each contain one coordinate in the format latitude,longitude
.
For example, if the input is:
4 51.5014,-0.1419 33.9416,-118.4085 51.5014,-0.1419 48.8566,2.3522
Then the output should be:
51.5014,-0.1419
inputFormat
The first line of input contains a single integer n (0 ≤ n ≤ 105) which is the number of coordinates. Each of the next n lines contains a coordinate in the format latitude,longitude
(for example: 51.5014,-0.1419
).
outputFormat
Output a single line containing the next most frequently visited coordinate. If there are ties, output the one that appeared first in the input. If there are no coordinates, output an empty line.
## sample4
51.5014,-0.1419
33.9416,-118.4085
51.5014,-0.1419
48.8566,2.3522
51.5014,-0.1419