Created
August 29, 2016 17:27
-
-
Save osmelmora/6c76d21b23cc78ce6ddb6306bae472e7 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
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