Last active
September 19, 2020 14:44
-
-
Save TheAlienMann/70ba55aa0572068589db0dd85201dfe9 to your computer and use it in GitHub Desktop.
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
@Override | |
public String replaceThe(String str) { | |
StringBuilder res = new StringBuilder(); | |
String vo = "aeiou"; | |
String[] part = str.split("the"); | |
res.append(part[0]); | |
for (int i = 1; i < part.length; i++) { | |
if (vo.contains(part[i].trim().charAt(0) + "")) { | |
res.append("an"); | |
} else { | |
res.append("a"); | |
} | |
res.append(part[i]); | |
} | |
return res.toString(); | |
} | |
@Override | |
public String longestZero(String str) { | |
String result = ""; | |
for (String s : str.split("1+")) { | |
if (result.length() < s.length()) { | |
result = s; | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment