Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 704 Bytes

README.md

File metadata and controls

24 lines (18 loc) · 704 Bytes

Detect Capital

Problem can be found in here!

def detectCapitalUse(word: str) -> bool:
    if len(word) == 1:
        return True

    if word[0].isupper() and word[1].isupper():
        for i in range(2, len(word)):
            if not word[i].isupper():
                return False
    else:
        for i in range(1, len(word)):
            if word[i].isupper():
                return False

    return True

Time Complexity: O(n), Space Complexity: O(1)