Determine whether the capitalization pattern of a word is valid.
Given a word, determine whether it uses capital letters correctly.
A word is considered to have correct capitalization if one of the following is true:
Return true if the word is correctly capitalized, otherwise return false.
word consisting of English letters.true if the capitalization is valid, otherwise return false.1 <= word.lengthword contains only alphabetic English letters.Example 1
Input
word = "USA"
Output
true
Explanation
All letters are uppercase.
Example 2
Input
word = "leetcode"
Output
true
Explanation
All letters are lowercase.
Example 3
Input
word = "Google"
Output
true
Explanation
Only the first letter is uppercase.
Example 4
Input
word = "FlaG"
Output
false
Explanation
The capitalization does not match any allowed pattern.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.