Longest Word in a Sentence
Riverbend Signs cuts banner lettering from a roll, and the roll has to be wide enough for the longest word in the slogan — a word cannot be broken across two lines. The shop also has a house rule for slogans where several words are equally long: they quote for the first of them, because that is the one the setter reaches for and the quote has to be repeatable.
Task: Print the longest word in the slogan.
Input
A single line holding between 1 and 1000 words made of lowercase letters, separated by single spaces.
Output
One line holding the longest word, exactly as it appeared. If two or more words are equally long and nothing else is longer, print whichever of them appears earliest in the line.
Example:
Input:
the quick brown fox jumps
Output:
quick
(both "quick" and "brown" have 5 letters, but "quick" comes first)
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in