原题
思路
简单题,用StringBuilder减少资源开销
代码
package leetcode.Algorithms;public class Solution_1119 {
public static void main(String[] args) {
System.out.println(removeVowels("leetcodeisacommunityforcoders"));}public static String removeVowels(String s) {
StringBuilder stringBuilder = new StringBuilder();char[] chars = s.toCharArray();for (int i = 0; i < chars.length; i++) {
if (chars[i] != 'a' && chars[i] != 'e' && chars[i] != 'i' && chars[i] != 'o' && chars[i] != 'u') {
stringBuilder.append(chars[i]);}}return stringBuilder.toString();}}