[LeetCode]345. Reverse Vowels of a String
来源:互联网 发布:网络书香过大年 编辑:程序博客网 时间:2024/06/05 08:45
[LeetCode]345. Reverse Vowels of a String
题目描述
思路
从前往后,从后往前分别找元音字母,若找到且满足前后的位置关系则交换
代码
#include <iostream>#include <string>#include <algorithm>using namespace std;class Solution {public: string reverseVowels(string s) { string vowels = "aeiouAEIOU"; int start = 0, end = s.size() - 1; while (start < end) { start = s.find_first_of(vowels, start); end = s.find_last_of(vowels, end); if (start < end) swap(s[start++], s[end--]); } return s; }};int main() { Solution s; cout << s.reverseVowels("Aa") << endl; system("pause"); return 0;}
阅读全文
0 0
- LeetCode 345. Reverse Vowels of a String
- leetcode-345. Reverse Vowels of a String
- #leetcode#345. Reverse Vowels of a String
- [leetcode] 345. Reverse Vowels of a String
- Leetcode:345. Reverse Vowels of a String
- LeetCode *** 345. Reverse Vowels of a String
- LeetCode.345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- Leetcode 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- 345.[LeetCode]Reverse Vowels of a String
- Leetcode 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- leetcode 345. Reverse Vowels of a String
- 【leetcode】345. Reverse Vowels of a String
- LeetCode-345.Reverse Vowels of a String
- LeetCode - 345. Reverse Vowels of a String
- [Leetcode]345. Reverse Vowels of a String
- python应用中一个具体问题的效率对比
- 抓猫_KEY
- stringbuilder
- spring整合jax-ws时报错(java.lang.IllegalStateException: BeanFactory not initialized or already closed)
- gridview的一些事件
- [LeetCode]345. Reverse Vowels of a String
- java反射机制
- ffmpeg编码常见问题排查方法
- PE添加节_最后节表后无空白字节
- USACO
- Fizz Buzz
- 链表学习(4)
- 关于下午3点整改会议,具体解决方案
- 入门Webpack