LeetCode知识点总结 – 345
LeetCode 168. Excel Sheet Column Title
考点难度StringEasy
题目
Given a string s, reverse only all the vowels in the string and return it.
The vowels are ‘a’, ‘e’, ‘i’, ‘o’, and ‘u’, and they can appear in both cases.
思路
用两个pointer,现判断是否都是vowel,如果不是就移动到最近的元音,之后swap两个位置上的字母。helper function:判断是否为vowel。
答案
public String reverseVowels(String s) {
if (s.length() == 0) return s;
char[] arr = s.toCha
共有 0 条评论