LeetCode:Reverse Vowels of a String
程序员文章站
2022-07-02 15:52:02
total accepted:8150total submissions:23213difficulty:easy
write a function that takes a string as i...
total accepted:8150total submissions:23213difficulty:easy
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".
subscribeto see which companies asked this question
hide tags
two pointersstring
hide similar problems
(e) reverse string
code:
public class solution { public boolean isvowel(char c) { if('a' <= c && c <= 'z') c += 'a'-'a'; return c=='a' || c=='e' || c=='i' || c=='o' || c=='u'; } public string reversevowels(string s) { int len = s.length(); char[] chs = s.tochararray(); int i=0,j=len-1; while(i
上一篇: 2018-10-23 23:29:54 clanguage
下一篇: 插入排序的三种算法C/C++
推荐阅读
-
Leetcode解题 7. Reverse Integer 反转整数
-
Reverse a String-freecodecamp算法题目
-
[c语言] 编写一个函数reverse_string(char * string)(递归实现)
-
Reverse a String-freecodecamp算法题目
-
Leetcode 7. Reverse Integer
-
LeetCode:7. Reverse Integer
-
【leetcode】7. Reverse Integer
-
【LeetCode】806. Number of Lines To Write String
-
Leetcode 1456. Maximum Number of Vowels in a Substring of Given Length (python)
-
【Leetcode】190. Reverse Bits(二进制数反转)