题目:

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) {string str = s;for (int i = 0, j = str.size() - 1; i < j; ){if (isVowel(str[i]) && isVowel(str[j])) {char tmp = str[i];str[i] = str[j];str[j] = tmp;i++;j--;}if ( !isVowel(str[i]))++i;if ( !isVowel(str[j])) --j;}return str;}bool isVowel(char c) {if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' \|| c == 'A' || c == 'E' || c == 'I' || c == 'U' || c == 'O') return true;return false;}
};

转载于:https://www.cnblogs.com/Doctengineer/p/5866768.html

【LeetCode】345. Reverse Vowels of a String 解题小结相关推荐

  1. 【LeetCode】345. Reverse Vowels of a String 解题报告

    转载请注明出处:http://blog.csdn.net/crazy1235/article/details/51429823 Subject 出处:https://leetcode.com/prob ...

  2. 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 ...

  3. 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 1 ...

  4. Leetcode 345: Reverse Vowels of a String

    问题描述: Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', ...

  5. Leetcode 345 Reverse Vowels of a String 字符串处理

    题意:倒置字符串中的元音字母. 用两个下标分别指向前后两个相对的元音字母,然后交换. 注意:元音字母是aeiouAEIOU. 1 class Solution { 2 public: 3 bool i ...

  6. 345. Reverse Vowels of a String - LeetCode

    Question 345. Reverse Vowels of a String Solution 思路:交换元音,第一次遍历,先把出现元音的索引位置记录下来,第二遍遍历元音的索引并替换. Java实 ...

  7. LeetCode:345. Reverse Vowels of a String

    051103 题目 Write a function that takes a string as input and reverse only the vowels of a string. Exa ...

  8. 345. Reverse Vowels of a String

    题目: Given a string s, reverse only all the vowels in the string and return it. The vowels are 'a', ' ...

  9. 345. Reverse Vowels of a String(python+cpp)

    题目: Write a function that takes a string as input and reverse only the vowels of a string. Example 1 ...

最新文章

  1. 总在说SpringBoot内置了tomcat启动,那它的原理你说的清楚吗?
  2. python的self
  3. MySQL-8.0.12源码安装实例
  4. 330 div+css Experience
  5. ICCV 2019 | 旷视研究院提出文字检测新方法:像素聚合网络PAN
  6. “常程跳槽小米”裁决出炉:常程继续履行竞业限制,还要赔500多万...
  7. 苹果7支持快充吗_iPhone12的磁吸无线充到底怎么回事?是否支持苹果20W快充?
  8. 【React性能优化】 redux优化
  9. 拓端tecdat|R语言时变向量自回归(TV-VAR)模型分析时间序列和可视化
  10. Ansible 自动化运维工具
  11. 林軒田《机器学习基石》课程总结
  12. 无线ac配置dhcp服务器,华硕RT-AC86U路由器怎么设置DHCP功能
  13. linux系统苹果刷机,iPhone上安装Android系统详细步骤
  14. bugku--never_give_up
  15. 怎么用python将日期转化为数字_python转化excel数字日期为标准日期操作
  16. 一张照片让你的安卓手机崩溃
  17. 计算机考研用python_2014北邮计算机考研复试上机题解(上午+下午)
  18. YoloV4当中的Mosaic数据增强方法(附代码讲解)
  19. 2022公司邮箱登录入口官网介绍,个人邮箱用户登录
  20. Fatal NI connect error 12170错误解决办法

热门文章

  1. js高级编号笔记[新]-访问文档对象
  2. yii selenium php,Yii 单元测试用例
  3. arduino接收hmi屏幕_汽车HMI设计中交互设计的发展趋势
  4. Oracle Spatial常用方法记录
  5. 如何使用go读写excel
  6. golang中tcp socket粘包问题和处理
  7. angularjs post返回html_Python 爬虫网页解析工具lxml.html(二)
  8. 关于字符集和字符编码格式
  9. hue的oozie的定时调度任务配置
  10. Object类的使用,包装类的使用