Skip to content

Instantly share code, notes, and snippets.

@bdimcheff
Created February 15, 2010 17:34
Show Gist options
  • Save bdimcheff/304818 to your computer and use it in GitHub Desktop.
Save bdimcheff/304818 to your computer and use it in GitHub Desktop.
require 'set'
class Array
# O(N)
def my_uniq
seen = Set.new
inject([]) do |uniqued, item|
uniqued << item unless seen.include? item
seen << item
uniqued
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment