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= int(input())
a= set(input().split())
b= int(input())
e = set(input().split())
r = a.intersection(e)
print (len(r))
We need to perform same technique like as we do in the union method. In this method also we have taken set method and everything but at the last instead of union we have used intersection as we require the common studebts using both the papers
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Set .intersection() Operation
You are viewing a single comment's thread. Return to all comments →
n= int(input()) a= set(input().split()) b= int(input()) e = set(input().split()) r = a.intersection(e) print (len(r)) We need to perform same technique like as we do in the union method. In this method also we have taken set method and everything but at the last instead of union we have used intersection as we require the common studebts using both the papers