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))
'algorithm > python' 카테고리의 다른 글
프로그래머스/탐욕법/체육복 (0) | 2020.03.16 |
---|---|
hackerrank/Stacks and Queues/Balanced Brackets (0) | 2020.03.09 |
hackerrank/String/Sherlock and the Valid String (0) | 2020.03.08 |
프로그래머스/완전탐색/모의고사 (0) | 2020.03.08 |
프로그래머스/힙/더 맵게 (0) | 2020.03.07 |