Skip to content

Instantly share code, notes, and snippets.

@awolf
Last active January 13, 2019 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awolf/c6db6df6876ea4962df5e54ea4a86f71 to your computer and use it in GitHub Desktop.
Save awolf/c6db6df6876ea4962df5e54ea4a86f71 to your computer and use it in GitHub Desktop.
Brain Freeze from Clojure - Java Version
public static int indexOfAny(String str, char[] searchChars) {
if (isEmpty(str) || ArrayUtils.isEmpty(searchChars)) {
return -1;
}
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
for (int j = 0; j < searchChars.length; j++) {
if (searchChars[j] == ch) {
return i;
}
}
}
return -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment