# 0345. Reverse Vowels of a String
###### tags: `Leetcode` `Easy` `Two Pointers`
Link: https://leetcode.com/problems/reverse-vowels-of-a-string/description/
## Code
str是不能变更的数据结构 如果需要变更 先把它转成list ```s=list(s)``` 然后最后再把字母用```''.join(s)```合并成str
```python=
class Solution:
def reverseVowels(self, s: str) -> str:
vowels = set(list("AEIOUaeiou"))
l, r = 0, len(s)-1
s = list(s)
while l<r:
if s[l] in vowels and s[r] in vowels:
s[l], s[r] = s[r], s[l]
l+=1
r-=1
if s[l] not in vowels:
l+=1
if s[r] not in vowels:
r-=1
return ''.join(s)
```