Skip to content

Instantly share code, notes, and snippets.

@0ryant
Created August 7, 2019 15:06
Show Gist options
  • Save 0ryant/33ce2968499bdbd6a4ccf8d8d8c936fe to your computer and use it in GitHub Desktop.
Save 0ryant/33ce2968499bdbd6a4ccf8d8d8c936fe to your computer and use it in GitHub Desktop.
Java - Coding Challenge - Do Two Numbers Share a Digit?
public static boolean hasSharedDigit(int num1, int num2) {
if ((num1 < 10) || (num1 > 99) ||
(num2 < 10) || (num2 > 99)) {
return false;
}
for (int i = num1; i != 0; i /= 10) {
for (int j = num2; j != 0; j /= 10) {
if (i%10 == j%10) {
return true;
}
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment