Last active
August 17, 2017 11:56
-
-
Save eduardopoleo/b4e621b908cb3a48dfa2ebe604e7d4ad 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
| 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