algorithm/python
hackerrank/Hash Tables/Ransom Note
아르르르를를르
2020. 3. 9. 00:29
https://www.hackerrank.com/interview/interview-preparation-kit/dictionaries-hashmaps/challenges
level1
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the checkMagazine function below.
def checkMagazine(magazine, note):
dict = {}
for item in magazine:
if item not in dict:
dict[item] = 1
else:
dict[item] += 1
for n in note:
if n not in dict:
return "No"
else:
dict[n] -= 1
if dict[n] == -1:
return "No"
return "Yes"
if __name__ == '__main__':
mn = input().split()
m = int(mn[0])
n = int(mn[1])
magazine = input().rstrip().split()
note = input().rstrip().split()
print (checkMagazine(magazine, note))