a = [1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 4, 5, 4, 34, 76]
Solution:
b = Hash.new 0
a.each do |k|
b[k] += 1
end
b.keys
Output:
=> [1, 2, 3, 4, 5, 6, 34, 76]
Solution:
b = Hash.new 0
a.each do |k|
b[k] += 1
end
b.keys
Output:
=> [1, 2, 3, 4, 5, 6, 34, 76]
No comments:
Post a Comment