#C10582. Longest Word Length
Longest Word Length
Longest Word Length
You are given a string s containing several words separated by spaces. Your task is to compute the length of the longest word in the string.
For example, given the string "the quick brown fox"
, the longest word is "quick"
or "brown"
with a length of 5
.
Note: Words are sequences of non-space characters. The input string may have leading or trailing spaces.
You can express the solution mathematically as follows: if the set of words is \(W = \{w_1, w_2, \dots, w_n\}\), then your answer is \(\max_{1 \le i \le n}(|w_i|)\), where \(|w_i|\) denotes the length of word \(w_i\).
inputFormat
The input consists of a single line containing the string s with words separated by spaces. The string may have extra spaces at the beginning or at the end.
outputFormat
Output a single integer representing the length of the longest word in the given string.
## samplethe quick brown fox
5
</p>