v1
- 栈 时间复杂度O(2n)
class Solution:
def reverseVowels(self, s: str) -> str:
l = ["a", "A", "e", "E", "i", "I", "o", "O", "U", "u"]
s_l = list(s)
stack = list()
for st in s_l:
if st in l:
stack.append(st)
for i in range(len(s_l)):
if s_l[i] in l:
p = stack.pop()
s_l[i] = p
return "".join(s_l)