#C2. Find the Longest Word
Find the Longest Word
Find the Longest Word
In this problem, you are given a single string s consisting of words separated by spaces. Your task is to find and output the longest word in the string. If there are multiple words that share the maximum length, you should return the one that appears first.
For example, given the input:
I love programming
the output should be:
programming
The problem requires careful handling of spaces and should work efficiently even when the input string contains many words.
inputFormat
The input consists of a single line containing the string s. The string may include spaces and consists only of printable characters.
outputFormat
Output the longest word from the input string. If multiple words have the same length, output the word that appears first.
## sampleI love programming
programming