Description
Given a word, return true if the usage of capitals in it is right: all letters are capitals, all are lowercase, or only the first letter is capital.
Examples
Input:
word = "USA"Output:
trueExplanation:
'USA' has all three letters in uppercase. This matches one of the valid patterns: all letters are capitals. Therefore, it returns true.
Input:
word = "FlaG"Output:
falseExplanation:
'FlaG' has capital F, lowercase l and a, then capital G. This mixed pattern doesn't match any valid rule (all caps, all lower, or first-only capital).
Input:
word = "leetcode"Output:
trueExplanation:
All letters are lowercase, which is a valid capitalization pattern.
Input:
word = "Google"Output:
trueExplanation:
Only the first letter is capitalized, which is a valid capitalization pattern.
Constraints
- •
1 ≤ word.length ≤ 100 - •
word consists of lowercase and uppercase English letters.