this question has answer here:
given have ruby array a = [1,2,3,2,4,4,2,5] how can select elements occurred multiple times in given array ?
so return value == [2,4]
a.group_by(&:itself).select{|_, a| a[1]}.keys this question has answer here:
given have ruby array a = [1,2,3,2,4,4,2,5] how can select elements occurred multiple times in given array ?
so return value == [2,4]
a.group_by(&:itself).select{|_, a| a[1]}.keys
Comments
Post a Comment