LeetCode p345 Reverse Vowels of a String 题解
1.题目:
Write a function that takes a string as input and reverse only the vowels of a string.
Example 1:
Given s = “hello”, return “holle”.
Example 2:
Given s = “leetcode”, return “leotcede”.
Note:
The vowels does not include the letter “y”.
题意:
输入一个字符串,将第一个元音字母与最后一个元音字母交换,第二个与倒数第二个交换。。以此类推。
2.解题思路:
两个指针搜索交换。
3.代码
1 |
|