Skip to content

Instantly share code, notes, and snippets.

@DenWav
Created September 25, 2015 01:18
Show Gist options
  • Save DenWav/3ad32d4bcbbfb7fc9ef6 to your computer and use it in GitHub Desktop.
Save DenWav/3ad32d4bcbbfb7fc9ef6 to your computer and use it in GitHub Desktop.
wat
public static boolean hasMoreVowels(String s) {
if (s.length() == 1)
return "aeiou".contains(s);
boolean removedVowel = false;
boolean removedCons = false;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
if ("aeiou".contains(s.substring(i, i + 1))) {
if (!removedVowel) {
removedVowel = true;
} else {
sb.append(s.substring(i, i + 1));
}
} else {
if (!removedCons) {
removedCons = true;
} else {
sb.append(s.substring(i, i + 1));
}
}
}
if (removedCons && removedVowel)
return hasMoreVowels(sb.toString());
else
return removedVowel;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment