Skip to content

Instantly share code, notes, and snippets.

@mahata
Created July 19, 2018 05:34
Show Gist options
  • Select an option

  • Save mahata/50e20bbbe679014ce4e37537572417e2 to your computer and use it in GitHub Desktop.

Select an option

Save mahata/50e20bbbe679014ce4e37537572417e2 to your computer and use it in GitHub Desktop.
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