public static void main(String[] args) throws IOException {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String word = "aeiuzzz";
final int inputLength = word.length();
if (inputLength >= 10000) {
System.err.println("The size of the string can not be greater than 10,000");
System.exit(1);
}
HashSet<Character> vowels = initializeVowels();
short found = 0;
for (final char c : word.toCharArray()) {
if (vowels.contains(c)) {
found++;
vowels.remove(c); //To avoid false positives.
}
}
String result = (found == vowels.size()) ? "yes" : "no";
System.out.println(result);
}
private static HashSet<Character> initializeVowels() {
HashSet<Character> vowels = new HashSet<Character>();
vowels.add('a');
vowels.add('e');
vowels.add('i');
vowels.add('o');
vowels.add('u');
return vowels;
}
In theory, this algorithm is more efficient and extensible. Though, considering that vowels is very small (5 elements), there probably wouldn't be a big difference. Still, it's good to see how it should be done. Though, consider vowels don't change very often, using a solution like @Eric's one will probably be faster.