Hash Tables Ransom Note: Looking for Hash Tables Ransom Note solution for Hackerrank problem? Get solution with source code and detailed explainer video.

Harold is a kidnapper who wrote a ransom note, but now he is worried it will be traced back to him through his handwriting. He found a magazine and wants to know if he can cut out whole words from it and use them to create an untraceable replica of his ransom note. The words in his note are case-sensitive and he must use only whole words available in the magazine. He cannot use substrings or concatenation to create the words he needs.
Given the words in the magazine and the words in the ransom note, print Yes if he can replicate his ransom note exactly using whole words from the magazine; otherwise, print No.
Go to problem statement

## Explanation Video:

Mentor: Satyendra Jaiswal
Langauge: Python

## Source Code:  for `checkMagazine` function

``````
# Complete the checkMagazine function below.
def checkMagazine(magazine, note):
flag=True
c1=Counter(magazine)
c2=Counter(note)
if c2-c1=={}:
print('Yes')
else:
print('No')
``````
coming soon…
coming soon…

## Full Source Code: Hash Tables: Ransom Note HackerRank Solution

``````
#!/bin/python3

import math
import os
import random
import re
import sys
from collections import Counter
# Complete the checkMagazine function below.
def checkMagazine(magazine, note):
flag=True
c1=Counter(magazine)
c2=Counter(note)
if c2-c1=={}:
print('Yes')
else:
print('No')

if __name__ == '__main__':
mn = input().split()

m = int(mn[0])

n = int(mn[1])

magazine = input().rstrip().split()

note = input().rstrip().split()

checkMagazine(magazine, note)

``````
coming soon…
coming soon…