hackerrank/interview_preparation_kit_dictionaries_and_hashmaps.rb
# Complete the checkMagazine function below.

Complete the checkMagazine function below.
Complete the checkMagazine function below .
def checkMagazine(magazine, note)
  chk1 = note - magazine == []
  chk2 = lambda do
    note_hash = note.group_by {|n| n}
    magazine_hash = magazine.group_by {|m| m}
    note_hash.keys.all? do |key|
      (magazine_hash[key].size || 0) >= note_hash[key].size
    end
  end
  puts chk1 && chk2.call ? 'Yes' : 'No'
end
def checkMagazine ( magazine , note ) chk1 = note - magazine == [ ] chk2 = lambda do note_hash = note . group_by { | n | n } magazine_hash = magazine . group_by { | m | m } note_hash . keys . all? do | key | ( magazine_hash [ key ] . size || 0 ) >= note_hash [ key ] . size end end puts chk1 && chk2 . call ? 'Yes' : 'No' end
Complete the checkMagazine function below.
Complete the checkMagazine function below .
magazine
<not_specific>
note
<not_specific>