diff --git a/src/main/java/com/thealgorithms/strings/CheckVowels.java b/src/main/java/com/thealgorithms/strings/CheckVowels.java index 21b536b5c7d5..dc59c04dd6c4 100644 --- a/src/main/java/com/thealgorithms/strings/CheckVowels.java +++ b/src/main/java/com/thealgorithms/strings/CheckVowels.java @@ -2,15 +2,12 @@ import java.util.Set; -/** - * Vowel Count is a system whereby character strings are placed in order based - * on the position of the characters in the conventional ordering of an - * alphabet. Wikipedia: https://en.wikipedia.org/wiki/Alphabetical_order - */ public final class CheckVowels { - private static final Set VOWELS = Set.of('a', 'e', 'i', 'o', 'u'); + + private static final Set VOWELS = Set.of('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'); private CheckVowels() { + // Private constructor to prevent instantiation } /** @@ -24,7 +21,8 @@ public static boolean hasVowels(String input) { return false; } - for (char c : input.toLowerCase().toCharArray()) { + for (int i = 0; i < input.length(); i++) { + char c = input.charAt(i); if (VOWELS.contains(c)) { return true; }