Skip to content

Instantly share code, notes, and snippets.

@matsko
Created September 29, 2012 04:43
Show Gist options
  • Save matsko/3803189 to your computer and use it in GitHub Desktop.
Save matsko/3803189 to your computer and use it in GitHub Desktop.
isUniqueChars(String str) {
if (str.length() > 256) return false;
int checker = 0;
for (int i = 0; i < str.length(); i++) {
int val = str.charAt(i) - 'a';
if ((checker & (i << val)) > 0) {
return false;
}
checker |= (1 << val);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment