Skip to content

Instantly share code, notes, and snippets.

@berkayk
Last active January 26, 2016 07:25
Show Gist options
  • Save berkayk/4bb0e4d99e0f2e69b197 to your computer and use it in GitHub Desktop.
Save berkayk/4bb0e4d99e0f2e69b197 to your computer and use it in GitHub Desktop.
public boolean checkUniqueness(String source) {
// Assumes that string includes ASCII characters (0-256)
if (source == null || source.length() == 0 || source.length() > 256) {
return false;
}
boolean[] seen = new boolean[256];
for (int i = 0; i < source.length(); i++) {
int temp = (int) source.charAt(i);
if (seen[temp]) {
return false;
}
seen[temp] = true;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment