c语言sscanf函数的用法是什么
234
2022-09-17
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: Given s = “hello”, return “holle”.
Example 2: Given s = “leetcode”, return “leotcede”.
Note: The vowels does not include the letter “y”.
public class Solution { static final String vowels = "aeiouAEIOU"; public String reverseVowels(String s) { int first = 0, last = s.length() - 1; char[] array = s.toCharArray(); while(first < last){ while(first < last && vowels.indexOf(array[first]) == -1){ first++; } while(first < last && vowels.indexOf(array[last]) == -1){ last--; } char temp = array[first]; array[first] = array[last]; array[last] = temp; first++; last--; } return new
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~