[LeetCode] 507. Perfect Number
Python
class Solution:
def detectCapitalUse(self, word: str) -> bool:
if word.upper() == word or word.lower() == word:
return True
elif word[0] == word.upper()[0] and word[1:] == word.lower()[1:]:
return True
else:
return False
댓글남기기