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:true
Explanation:

'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:false
Explanation:

'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:true
Explanation:

All letters are lowercase, which is a valid capitalization pattern.

Input:word = "Google"
Output:true
Explanation:

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.

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!