Easy
Quiz
#520 Detect Capital
APPROACH
Capitalization in a word is considered correct if exactly one of these three patterns holds:
- Every letter is uppercase, e.g. "USA".
- Every letter is lowercase, e.g. "leetcode".
- Only the very first letter is uppercase, e.g. "Google".
Given a string word, return true if its capitalization is correct, and false otherwise.
Example 1:
Input: word = "USA"
Output: true
Example 2:
Input: word = "FlaG"
Output: false
1 of 4
1:00
What is the optimal approach for this problem?