HackerRank Ruby Hash – Each problem solution YASH PAL, 31 July 2024 In this HackerRank Ruby Hash – Each problem solution the control structure each used on an array. Similarly, it is available for the Hash collection, as well.On Hash, it works in two ways.Consider the exampleuser = {“viv” : 10, “simmy” : 20, “sp2hari” : 30} Using each, each element can be iterated asuser.each do |key, value| # some code on individual key, valueendoruser.each do |arr| # here arr[0] is the key and arr[1] is the valueendYour task is to use each and iterate through the collection and print the key-value pair in separate lines.Problem solution.def iter_hash(hash) hash.each do |key, value| puts key puts value end end Second solution.def iter_hash(h) h.each {|k,v| puts k,v } end coding problems solutions Ruby Solutions