#K3126. Longest Word Finder
Longest Word Finder
Longest Word Finder
You are given a string s
containing one or more words separated by whitespace. Your task is to find and print the longest word in the string. In the case where multiple words have the same maximum length, output the first occurrence.
Note: The string may contain punctuation, and these punctuation marks are considered part of the words.
For example, given the input "I love programming challenges
", the output should be "programming
".
The solution should read input from stdin
and output the result to stdout
.
inputFormat
The input consists of a single line containing a string s
with one or more words separated by whitespace.
You can assume that there is at least one word in the input.
outputFormat
Output the longest word found in the input string. If there are multiple words with the same maximum length, output the one that appears first.
## sampleI love programming challenges
programming