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.
Set .intersection() Operation
Set .intersection() Operation
Sort by
recency
|
446 Discussions
|
Please Login in order to post a comment
a = int(input()) b = set(map(int, input().split())) c = int(input()) d = set(map(int, input().split()))
e = b.intersection(d) count = 0 for i in range(len(e)): count = count+1
print(count)
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
a=int(input()) n=set(map(int,input().split())) b=int(input()) c=set(map(int,input().split())) r=n.intersection(c) print(len(r))
n = int(input()) n1 = set(map(int,input().split())) b = int(input()) b1 = set(map(int,input().split())) both_subscribed = n1.intersection(b1) print(len(both_subscribed))