#K7801. Longest Word Finder
Longest Word Finder
Longest Word Finder
Given a sentence consisting of words separated by spaces, your task is to find and output the longest word in the sentence. If there are several words with the same maximum length, output the one that appears first in the sentence. Note that if the sentence is empty, the output should be an empty string. In mathematical terms, if the sentence is split into words (w_1, w_2, \dots, w_n), you are to find (w_k) such that (|w_k| = \max_{1 \leq i \leq n} |w_i|) and (k) is the smallest index among all words with the maximum length.
inputFormat
The input consists of a single line which is a string of words separated by spaces. The string may be empty.
outputFormat
Print the longest word found in the input string. If there are multiple words with the same maximum length, print the first one. If the input is empty, print an empty string.## sample
the quick brown fox jumped over the lazy dog
jumped