#C9914. Longest Word Length
Longest Word Length
Longest Word Length
Given a string s containing words separated by spaces, your task is to determine the length of the longest word in the string.
If the string is empty or contains only whitespace characters, output 0.
Mathematically, if we denote the set of words in s as \(W\), you are to compute:
\(\max\{ |w| : w \in W \}\)
Note that words are defined as consecutive sequences of non-space characters.
Examples:
- For
s = "hello"
, the output is5
. - For
s = "The quick brown fox"
, the output is5
(since "quick", "brown", and "fox" all have lengths of 5 or less). - For
s = " hello world "
, the output is5
. - For an empty string, the output is
0
.
inputFormat
The input consists of a single line containing the string s. The string may contain leading or trailing spaces. Words in the string are separated by one or more spaces.
Input is provided via stdin.
outputFormat
Output a single integer representing the length of the longest word in the input string. The result should be printed to stdout.
## sample
0