Created
September 25, 2015 01:18
-
-
Save DenWav/3ad32d4bcbbfb7fc9ef6 to your computer and use it in GitHub Desktop.
wat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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