Last active
January 26, 2016 07:25
-
-
Save berkayk/4bb0e4d99e0f2e69b197 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
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