345. Reverse Vowels of a String
来源:互联网 发布:朝鲜奢侈生活知乎 编辑:程序博客网 时间:2024/06/02 05:35
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”.
class Solution {public: string reverseVowels(string s) { int i = 0; int j = s.length() - 1; while(i < j) { while(i<j && !isVowels(s[i])) { i++; } while(i<j && !isVowels(s[j])) { j--; } swap(s[i++],s[j--]); } return s; } bool isVowels(char c) { return c== 'a' || c== 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'; }};
0 0
- String:345. Reverse Vowels of a String
- 345. Reverse Vowels of a String 【E】
- LeetCode 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- leetcode-345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- #leetcode#345. Reverse Vowels of a String
- [leetcode] 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- Leetcode:345. Reverse Vowels of a String
- LeetCode *** 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- LeetCode.345. Reverse Vowels of a String
- 345. Reverse Vowels of a String
- LeetCode 345. Reverse Vowels of a String
- 139_Transformer源码分析
- ie6兼容性问题
- css border那点事
- DirectFB的架构介绍
- win7常用cmd命令
- 345. Reverse Vowels of a String
- SQL Server 2008安装报错:The specified credentials for the sql server service are not valid
- leetcode-8
- 140_自定义ViewPager
- jdbc,if(res.next)判断结果失败
- NOJ——1508火烧赤壁2(并查集+启发式合并+逆序加边)
- 141_自定义Transformer
- Java操作Excel文件以及将xls/xlsx转为csv文件
- Spark Streaming源码解读之Job动态生成和深度思考