#C13114. Longest Word Finder
Longest Word Finder
Longest Word Finder
You are given a string of words separated by spaces. Your task is to find and output the longest word in the string. If there are multiple words with the same maximum length, output the one that appears first in the string. If the input string is empty, output an empty string.
Note: Words are defined as sequences of characters separated by spaces. Punctuation is considered part of a word.
For example, for the input \(\text{The complexity of a coding problem can vary}\)
, the longest word is \(\text{complexity}\)
.
inputFormat
The input consists of a single line containing a string of words separated by spaces. The string may be empty.
outputFormat
Output the longest word in the string. If there are multiple words of the same length, output the first encountered. If the input is empty, output an empty string.
## sampleThe complexity of a coding problem can vary
complexity