#C3776. Longest Word
Longest Word
Longest Word
Given a string s, find the length of the longest word in the string. A word is defined as a contiguous sequence of non-space characters. Formally, if we denote the set of words in s as \(W\), you are to compute
[ \max_{w \in W} |w| ]
If the string does not contain any valid word (i.e. it is empty or contains only spaces), output 0.
Example:
Input: the quick brown fox jumps over the lazy dog Output: 5
inputFormat
The input is provided via standard input (stdin) as one or more lines forming a single string s. The string may contain leading, trailing, or multiple spaces between words.
outputFormat
Output to standard output (stdout) the integer representing the length of the longest word in the input string.
## samplethe quick brown fox jumps over the lazy dog
5