Reverse Vowels of a String
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".
char* reverseVowels(char* s) {
int i;
int j;
char temp;
i = ;
j = strlen(s) - ;
while(i < j){
if(s[i] != 'a' && s[i] != 'e' && s[i] != 'i' && s[i] != 'o' && s[i] != 'u' && s[i] != 'A' && s[i] != 'E' && s[i] != 'I' && s[i] != 'O' && s[i] != 'U')
i++;
if(s[j] != 'a' && s[j] != 'e' && s[j] != 'i' && s[j] != 'o' && s[j] != 'u' && s[j] != 'A' && s[j] != 'E' && s[j] != 'I' && s[j] != 'O' && s[j] != 'U')
j--;
if((s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o'|| s[i] == 'u' || s[i] == 'A' || s[i] == 'E'|| s[i] == 'I'|| s[i] == 'O'|| s[i] == 'U') && (s[j] == 'a' || s[j] == 'e' || s[j] == 'i' || s[j] == 'o'|| s[j] == 'u' || s[j] == 'A' || s[j] == 'E'|| s[j] == 'I'|| s[j] == 'O'|| s[j] == 'U'))
{
temp = s[i];
s[i] = s[j];
s[j] = temp;
i++;
j--;
}
}
return s;
}
Reverse Vowels of a String的更多相关文章
- 345. Reverse Vowels of a String(C++)
345. Reverse Vowels of a String Write a function that takes a string as input and reverse only the v ...
- 【leetcode】345. Reverse Vowels of a String
problem 345. Reverse Vowels of a String class Solution { public: string reverseVowels(string s) { , ...
- 345. Reverse Vowels of a String【easy】
345. Reverse Vowels of a String[easy] Write a function that takes a string as input and reverse only ...
- LeetCode_345. Reverse Vowels of a String
345. Reverse Vowels of a String Easy Write a function that takes a string as input and reverse only ...
- 345. Reverse Vowels of a String - LeetCode
Question 345. Reverse Vowels of a String Solution 思路:交换元音,第一次遍历,先把出现元音的索引位置记录下来,第二遍遍历元音的索引并替换. Java实 ...
- [LeetCode] Reverse Vowels of a String 翻转字符串中的元音字母
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...
- LeetCode Reverse Vowels of a String
原题链接在这里:https://leetcode.com/problems/reverse-vowels-of-a-string/ 题目: Write a function that takes a ...
- 345. Reverse Vowels of a String
Write a function that takes a string as input and reverse only the vowels of a string. Example 1:Giv ...
- Python [Leetcode 345]Reverse Vowels of a String
题目描述: Write a function that takes a string as input and reverse only the vowels of a string. Example ...
随机推荐
- android界面布局技巧(一)
(1)//得到手机的宽高 Display display = getWindowManager().getDefaultDisplay(); int screenWidth = display.get ...
- 数据结构-多级指针单链表(C语言)
偶尔看到大一时候写了一个多级链表,听起来好有趣,稍微整理一下. 稍微注意一下两点: 1.指针是一个地址,他自己也是有一个地址.一级指针(带一个*号)表示一级地址,他自身地址为二级地址.二级指针(带两个 ...
- c++引用小问题!
两段程序 string version(const string &s1,const string &s2) { string temp; temp =s2+s1+s2; return ...
- tar: 从成员名中删除开头的“/”
在压缩文件时,当后面的备份目录使用绝对路径时,会出现: tar zcvf /usr/OutFile.tar.gz /data/CTest tar: 从成员名中删除开头的“/” 此时,对tar增加 ...
- Leetcode005 Longest Palindromic Substring
o(n)算法地址:http://blog.163.com/zhaohai_1988/blog/static/2095100852012716105847112/ /* pivot varies whe ...
- .NET Reflector反编译的方法
首先启动.NET Reflector,然后添加进入dll或exe.然后选择Export Source Code...,将反编译后的代码文件,生成到指定目录. 到这一步骤时,稍等一会,就能够在指定目录就 ...
- jQuery之Nestable
空间属性置顶: 属性 说明 change 事件,当控件改变时触发 nestable 方法,获取顺序JSON数据,形式如下: [{"id":1},{"id":2} ...
- Hadoop SecondaryNameNode备份及恢复
1.同步各个服务器时间 yum install ntp ntpdate ntp.fudan.edu.cn hdfs-site.xml配置 如果没有配置这一项,hadoop默认是0.0.0.0:5009 ...
- JavaScript空判断
if(backInfo != "" && backInfo != null && typeof(backInfo)!="undefined ...
- Android IOS WebRTC 音视频开发总结(四一)-- QQ和webrtc打洞能力pk
很多人知道webrtc打洞能力很强,到底有多强但是不知道,比较好的方法就是跟QQ对比,但大多数公司很难模拟各种网络环境进行测试,比如联通,铁通,电信,移动,所以这次请小师妹在实验室下进行了一个比较全面 ...