#C14746. Longest Word Finder
Longest Word Finder
Longest Word Finder
You are given a list of words. Your task is to find and print the longest word in the list. If there are multiple words that have the same maximum length, output the one that appears first in the list. If the list is empty, print an empty string.
Let \( |s| \) denote the length of the string s. You need to choose the word \( w \) such that for any word \( v \) in the list, \( |w| \geq |v| \) holds, and if \( |w| = |v| \), then \( w \) appears before \( v \) in the list.
Example:
Input: 4 apple banana cherry date</p>Output: banana
inputFormat
The first line contains an integer \( n \) representing the number of words. Each of the following \( n \) lines contains a single word. If \( n = 0 \), there are no words and you should output an empty string.
outputFormat
Output a single line containing the longest word. If there are multiple words with the same maximum length, output the one that appears first. If no words are provided, output an empty string.
## sample4
apple
banana
cherry
date
banana
</p>