A sentence consists of tokens separated by one or more spaces. A token is defined as a contiguous sequence of non-space characters.
A token is considered a valid word if it satisfies all of the following conditions:
It does not contain any digits, consisting only of lowercase English letters, hyphens '-', and punctuation marks ('!', '.', and ',').
It contains at most '-'. If present, the hyphen must be surrounded by lowercase English letters on both sides.
It contains at most
Given a string sentence, return the number of valid words in sentence.
Constraints:
sentence.length
sentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.
There will be at least
A sentence consists of tokens separated by one or more spaces. A token is defined as a contiguous sequence of non-space characters.
A token is considered a valid word if it satisfies all of the following conditions:
It does not contain any digits, consisting only of lowercase English letters, hyphens '-', and punctuation marks ('!', '.', and ',').
It contains at most '-'. If present, the hyphen must be surrounded by lowercase English letters on both sides.
It contains at most
Given a string sentence, return the number of valid words in sentence.
Constraints:
sentence.length
sentence only contains lowercase English letters, digits, ' ', '-', '!', '.', and ','.
There will be at least