일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 쓰릴오브파이트
- 월간
- 괜찮음
- 읽기
- 파비최
- 30분
- 만화도
- Writing
- leetcode
- English
- 개발자
- 화상영어
- 영어공부
- 뭐든
- 잡생각
- 미드시청
- 운동
- 스탭퍼
- 링피트
- FIT XR
- 3줄정리
- Problem Solving
- 리얼 클래스
- 영어원서읽기
- 매일
- 10분
- 프로젝트
Archives
- Today
- Total
파비의 매일매일 공부기록
Today's Challenge 본문
https://leetcode.com/problems/reverse-vowels-of-a-string/
Reverse Vowels of a String - 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
생각보다는 어려운 문제였음.. 난이도에 속음 =_=
class Solution:
def reverseVowels(self, s: str) -> str:
def is_vowel(c):
return c in ['a', 'i', 'e', 'o', 'u', 'A', 'I', 'E', 'O', 'U']
start, end = 0, len(s) - 1
res = list(s)
while start < end:
while start < len(res) and not is_vowel(res[start]):
start += 1
while end >= 0 and not is_vowel(res[end]):
end -= 1
if start < end:
temp = res[start]
res[start] = res[end]
res[end] = temp
start += 1
end -= 1
return ''.join(res)
반응형
'Problem Solving > LeetCode' 카테고리의 다른 글
Today's Challenge (0) | 2022.11.06 |
---|---|
Today's Challenge (0) | 2022.11.05 |
Today's Challenge (0) | 2022.11.03 |
Today's Challenge (0) | 2022.11.02 |
Today's Challenge (0) | 2022.11.01 |
Comments