Created
July 19, 2018 05:34
-
-
Save mahata/50e20bbbe679014ce4e37537572417e2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| fun isUniqueChars(str: String): Boolean { | |
| if (str.length > 256) return false | |
| var checker: Int = 0 | |
| for (idx in 0..(str.length-1)) { | |
| val value: Int = str[idx] - 'a' | |
| if ((checker and (1 shl value)) > 0) { | |
| return false | |
| } | |
| checker = checker or (1 shl value) | |
| } | |
| return true | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment