Python solution


  • 0
    A

    class Solution(object):
    def detectCapitalUse(self, word):
    """
    :type word: str
    :rtype: bool
    """
    if len(word)==1:
    return True
    else:
    if word[0].isupper():
    word = word[1:]
    if len(word)==1:
    return True
    else:
    if word[0].isupper():
    for i in range(1, len(word)):
    if word[i].islower():
    return False
    return True
    else:
    for i in range(1, len(word)):
    if word[i].isupper():
    return False
    return True
    else:
    for i in range(1, len(word)):
    if word[i].isupper():
    return False
    return True


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.