I have an array like [1,1,1,2,4,6,3,3] and I would like to get the list of repeated elements, in this case [1,3]. I wrote this:
my_array.select{|obj|my_array.count(obj)>1}.uniq
But it is tragically inefficient (o(n²)). Do you have a better idea? If possible concise.
Thanks