Last active
January 13, 2019 17:39
-
-
Save awolf/c6db6df6876ea4962df5e54ea4a86f71 to your computer and use it in GitHub Desktop.
Brain Freeze from Clojure - Java Version
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 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