#C14282. Longest Word Finder
Longest Word Finder
Longest Word Finder
Given a sentence, your task is to find the longest word in that sentence. If multiple words have the same maximum length, output the first one encountered.
The input consists of a single line with the sentence, and words are defined as sequences of non-space characters. You may assume that the sentence contains at least one word.
You can think of the process as comparing the lengths of words: \(\text{if } len(word_1) > len(word_2)\), then word_1 is considered longer.
inputFormat
The input is provided via standard input containing a single line. This line is a sentence consisting of words separated by spaces.
outputFormat
Output the longest word found in the sentence to standard output. If more than one word has the maximum length, output the first occurrence.## sample
The quick brown fox jumped over the lazy dog
jumped