#C8720. Find the Longest Word
Find the Longest Word
Find the Longest Word
Given a string, your task is to find the longest word within it. The word is defined as a contiguous sequence of non-space characters. If there are multiple words of the same maximum length, return the first one encountered in the string.
Input Example: "I love programming"
Output Example: "programming"
Note: The solution must read input from stdin
and output the result to stdout
. The output should be exactly the longest word found.
inputFormat
The input consists of a single line of text that may include spaces. This text represents the sentence from which you need to extract the longest word.
outputFormat
Output the longest word from the provided sentence. If the input is an empty string, output an empty string.
## sampleI love programming
programming