#C7016. Longest Word Length
Longest Word Length
Longest Word Length
Given a string, determine the length of its longest word. A word is defined as a sequence of English letters (a-z, A-Z) and may include hyphens (-). All punctuation and other non-letter characters are ignored. For example, in the input "Hello world! This is an example-string.", the longest word is "example-string" with a length of 14. If no valid word exists, the output should be 0.
More formally, if we denote a word by the regular expression \(\texttt{[a-zA-Z\-]+}\), then the answer is given by:
[\max_{w \in \mathcal{W}} \text{length}(w)]
where \(\mathcal{W}\) is the set of all words found in the input string.
inputFormat
The input consists of a single string provided via standard input (stdin). This string may contain spaces, punctuation marks, numbers, and special characters.
outputFormat
Output a single integer to standard output (stdout) representing the length of the longest word found in the input string. If the input contains no valid words, output 0.
## sampleHello world! This is an example-string.
14