Skip to content

Practice Detect Capital

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#520
LeetCode Problem

Detect Capital

Problem Statement

Return whether a word uses one of these capitalization patterns: every letter is uppercase, every letter is lowercase, or only the first letter is uppercase and all following letters are lowercase. For example, USA, leetcode and Google are valid; FlaG is not.

Source: Detect Capital on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
word = "USA"
Output
true

# Example 2

Input
word = "FlaG"
Output
false

Constraints

1 <= word.length <= 100
word consists of lowercase and uppercase English letters.

Related LeetCode Problems

Practice more problems similar to Detect Capital.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.