Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Given s = "hello", return "holle".
Given s = "hello", return "holle".
Example 2:
Given s = "leetcode", return "leotcede".
Given s = "leetcode", return "leotcede".
Note:
The vowels does not include the letter "y".
<Solution>The vowels does not include the letter "y".
思考如下
- 用一個 HashSet 來查目前的字母是不是母音
- 用兩個指標,分別從兩端開始找母音,找到就交換
Java
C++
沒有留言:
張貼留言