LeetCode编程练习

来源:互联网 发布:淘宝漏洞q币充值 编辑:程序博客网 时间:2024/06/02 04:03

题目:

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

      Note:
      The vowels does not include the letter "y".
 

   编写一个函数,它以字符串作为输入,只返回字符串的元音。元音不包括字母“y”。

   示例1: 输入s = "hello",返回" holle "。

   示例2: 输入s = "leetcode ",返回" leotcede "。


思路:

   元音字母有五个a,e,i,o,u,大写的也算,当首尾指针所遍历的元素均为元音字母的时候进行交换。






原创粉丝点击