일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 프로젝트
- 파비최
- 링피트
- 스탭퍼
- 30분
- 미드시청
- 쓰릴오브파이트
- 영어원서읽기
- 잡생각
- leetcode
- realclass
- 영어공부
- 월간
- 매일
- 괜찮음
- 뭐든
- 운동
- 개발자
- 화상영어
- Daily Challenge
- 3줄정리
- 읽기
- FIT XR
- 만화도
- 사이드
- Problem Solving
- Writing
- 10분
- English
- 리얼 클래스
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/detect-capital/
Detect Capital - LeetCode
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
leetcode.com
매우 간단스한 문제.
문자열을 조건대로 변환해서 비교하면 끝!
class Solution:
def detectCapitalUse(self, word: str) -> bool:
if word.upper() == word:
return True
if word.lower() == word:
return True
if word.upper()[:1] + word.lower()[1:] == word:
return True
return False
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2023.01.04 |
---|---|
Today's Challenge (0) | 2023.01.03 |
Today's Challenge (0) | 2023.01.01 |
Today's Challenge (0) | 2022.12.31 |
Today's Challenge (0) | 2022.12.30 |
Comments