We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
n,m=input().split()
array=tuple(input().split())
s=set(array)
t_set_1=set(input().split())
t_set_2=set(input().split())
happiness=0
fre=Counter(array)
for i in t_set_1.intersection(array):
happiness+=fre[i]
for i in t_set_2.intersection(array):
happiness-=fre[i]
print(happiness)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
No Idea!
You are viewing a single comment's thread. Return to all comments →
from collections import Counter
n,m=input().split() array=tuple(input().split()) s=set(array) t_set_1=set(input().split()) t_set_2=set(input().split()) happiness=0 fre=Counter(array) for i in t_set_1.intersection(array): happiness+=fre[i] for i in t_set_2.intersection(array): happiness-=fre[i]
print(happiness)