| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- Daily Challenge
- 운동
- 개발자
- realclass
- 10분
- leetcode
- 3줄정리
- 사이드
- Writing
- 쓰릴오브파이트
- 뭐든
- 읽기
- 30분
- 미드시청
- FIT XR
- 파비최
- 잡생각
- 괜찮음
- 영어공부
- 월간
- 리얼 클래스
- 프로젝트
- 만화도
- 화상영어
- Problem Solving
- 스탭퍼
- 매일
- 영어원서읽기
- 링피트
- English
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/determine-if-string-halves-are-alike/
Determine if String Halves Are Alike - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
더하고 빼기만 잘하면 되는 문제. lowercase로 바꿔도 상관 없어서 걍 바꿔서 처리함
class Solution:
def halvesAreAlike(self, s: str) -> bool:
s = s.lower()
vowels = ['a', 'e', 'i', 'o', 'u']
l, h, cnt = len(s), len(s) // 2, 0
for i in range(l):
if s[i] in vowels:
if i < h:
cnt += 1
else:
cnt -=1
return cnt == 0반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
| Today's Challenge (0) | 2022.12.03 |
|---|---|
| Today's Challenge (0) | 2022.12.02 |
| Today's Challenge (0) | 2022.11.30 |
| Today's Challenge (0) | 2022.11.29 |
| Today's Challenge (0) | 2022.11.28 |
Comments