Skip to content

Instantly share code, notes, and snippets.

@osmelmora
Created August 29, 2016 17:27
Show Gist options
  • Save osmelmora/6c76d21b23cc78ce6ddb6306bae472e7 to your computer and use it in GitHub Desktop.
Save osmelmora/6c76d21b23cc78ce6ddb6306bae472e7 to your computer and use it in GitHub Desktop.
function allUniqueChars(str) {
if(!str) return false;
let checker = 0;
let flagIndex;
const length = str.length;
for (let i = 0; i < length; i++) {
flagIndex = str[i].charCodeAt(0) - 'a'.charCodeAt(0);
if ((checker & (1 << flagIndex)) > 0) return false;
checker |= (1 << flagIndex);
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment