Skip to content

Instantly share code, notes, and snippets.

@eduardopoleo
Last active August 17, 2017 11:56
Show Gist options
  • Save eduardopoleo/b4e621b908cb3a48dfa2ebe604e7d4ad to your computer and use it in GitHub Desktop.
Save eduardopoleo/b4e621b908cb3a48dfa2ebe604e7d4ad to your computer and use it in GitHub Desktop.
def unique_with_bit_array(s)
vector = 0
s.each_char do |char|
code = char.ord
if (vector & (1 << code)) > 0
return false
end
vector |= (1 << code)
end
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment