1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
class Solution:
def reverseVowels(self, s: str) -> str:
vowels=['a','e','i','o','u','A','E','I','O','U']
my_vowel=[]
start=0
ans=''
for i in s:
if i in vowels : my_vowel.append(i)
my_vowel=my_vowel[::-1]
for i in s:
if i in vowels :
ans+=my_vowel[start]
start+=1
else: ans+=i
return(ans)
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
백준 24510 시간복잡도를 배운 도도 (0) | 2022.04.21 |
---|---|
백준 25024 시간과 날짜 (0) | 2022.04.21 |
leetcode 504. Base 7 (0) | 2022.04.18 |
leetcode 1752. Check if Array Is Sorted and Rotated (0) | 2022.04.18 |
leetcode 1796. Second Largest Digit in a String (0) | 2022.04.18 |
댓글