#K39822. Longest Word Finder
Longest Word Finder
Longest Word Finder
You are given a list of words and you need to find the word with the maximum length. In case there are multiple words with the same maximum length, you should output the one that appears first. More formally, if the list of words is (W = [w_1, w_2, \dots, w_n]), find (w_k) such that (|w_k| \ge |w_i|) for all (i) and if (|w_k| = |w_j|) for some (j < k) then choose (w_j). If the list is empty, output an empty string.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (n) (where (0 \le n \le 10^5)), which represents the number of words. The following (n) lines each contain a single word composed of lowercase English letters.
outputFormat
Output to standard output (stdout) the word that has the maximum length among the (n) words. If there are multiple words with the maximum length, output the first one among them. If (n = 0), output an empty string.## sample
1
word
word