Skip to content

Commit d53e865

Browse files
committed
Add code for leetcode No.345
1 parent 5a4ed60 commit d53e865

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: leetcode-345/leetcode345.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution:
2+
def reverseVowels(self, s: str) -> str:
3+
vowels = ['A', 'E', 'I', 'O', 'U', 'a', 'e', 'i', 'o', 'u']
4+
vList = list()
5+
6+
vCount = 0
7+
for index in range(len(s)):
8+
if s[index] in vowels:
9+
vList.append(s[index])
10+
11+
res_str = ''
12+
vList.reverse()
13+
14+
vOutCount = 0
15+
for index in range(len(s)):
16+
if s[index] not in vowels:
17+
res_str += s[index]
18+
else:
19+
res_str += vList[vOutCount]
20+
vOutCount += 1
21+
22+
return res_str
23+
24+
sol = Solution()
25+
print(sol.reverseVowels("hiHeyBaby"))

0 commit comments

Comments
 (0)