Capitals are used correctly in a word if one of these holds: every letter is a capital (`"USA"`), no letter is a capital (`"leetcode"`), or only the first letter is a capital (`"Google"`). Given a string `word`, return `true` if its capitals are used correctly.
Capitals are used correctly in a word if one of these holds: every letter is a capital ("USA"), no letter is a capital ("leetcode"), or only the first letter is a capital ("Google"). Given a string word, return true if its capitals are used correctly.
Example 1:
Input: {"word":"USA"}
Output: true
Constraints:
1≤word.length≤100
word consists of lowercase and uppercase English letters.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"word":"USA"}
word; capitals are raised and blue once read
U
0
S
1
A
2
capitals 0
of
length 3
ALL CAPITALS
USA
✓ still possible
all lowercase
leetcode
✓ still possible
Only first capital
Google
✓ still possible
Count the capital letters. The three allowed shapes are: all capitals, no capitals, or exactly one capital in the first position.