- Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy path_1119.java
26 lines (23 loc) · 759 Bytes
/
_1119.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
packagecom.fishercoder.solutions.secondthousand;
importjava.util.Arrays;
importjava.util.HashSet;
importjava.util.Set;
publicclass_1119 {
publicstaticclassSolution1 {
publicStringremoveVowels(StringS) {
Set<Character> vowels = newHashSet<>(Arrays.asList('a', 'e', 'i', 'o', 'u'));
StringBuilderstringBuilder = newStringBuilder();
for (charc : S.toCharArray()) {
if (!vowels.contains(c)) {
stringBuilder.append(c);
}
}
returnstringBuilder.toString();
}
}
publicstaticclassSolution2 {
publicStringremoveVowels(StringS) {
returnS.replaceAll("[aeiou]", "");
}
}
}