#C8174. Longest Word Length
Longest Word Length
Longest Word Length
Given a sentence, your task is to determine the length of the longest word in it.
A word is defined as a consecutive sequence of non-space characters. Words are separated by one or more spaces. If the sentence is empty or contains no valid words, the answer should be 0.
This is a simple string processing problem. Make sure to handle extra spaces between words correctly.
Mathematically, if the sentence is represented as a sequence of words \( w_1, w_2, \ldots, w_n \), you must compute:
\( \max_{1 \le i \le n} |w_i| \)
where \(|w_i|\) denotes the length of the word \(w_i\).
inputFormat
A single line representing the sentence. The sentence may contain multiple spaces between words or be an empty string.
outputFormat
An integer printed to stdout indicating the length of the longest word in the input sentence.## sample
The quick brown fox jumps over the lazy dog
5