mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-04 16:12:47 +08:00
31 lines
577 B
Markdown
31 lines
577 B
Markdown
# [345. Reverse Vowels of a String](https://leetcode.com/problems/reverse-vowels-of-a-string/)
|
|
|
|
## 题目
|
|
|
|
Write a function that takes a string as input and reverse only the vowels of a string.
|
|
|
|
|
|
|
|
Example 1:
|
|
|
|
```c
|
|
Input: "hello"
|
|
Output: "holle"
|
|
```
|
|
|
|
Example 2:
|
|
|
|
```c
|
|
Input: "leetcode"
|
|
Output: "leotcede"
|
|
```
|
|
|
|
## 题目大意
|
|
|
|
题目要求我们反转字符串中的元音字母。需要注意字母大小写。
|
|
|
|
## 解题思路
|
|
|
|
这一题的解题思路是用 2 个指针,指针对撞的思路,来不断交换首尾元素,即可。这一题和第 344 题思路一样。
|
|
|