엔지니어 게시판
LeetCode 솔루션 분류

[1/2] 520. Detect Capital

컨텐츠 정보

본문

We define the usage of capitals in a word to be right when one of the following cases holds:

  • All letters in this word are capitals, like "USA".
  • All letters in this word are not capitals, like "leetcode".
  • Only the first letter in this word is capital, like "Google".

Given a string word, return true if the usage of capitals in it is right.

 

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.
Accepted
365.2K
Submissions
<div class="text
태그 ,

관련자료

댓글 1

학부유학생님의 댓글

  • 익명
  • 작성일
class Solution:
    def detectCapitalUse(self, word: str) -> bool:
        return len(word) == 1 or word[1:].islower() or word.isupper()
전체 396 / 1 페이지
번호
제목
이름

최근글


인기글


새댓글


Stats


  • 현재 접속자 167 명
  • 오늘 방문자 2,737 명
  • 어제 방문자 5,332 명
  • 최대 방문자 11,134 명
  • 전체 회원수 1,047 명
알림 0