Set .intersection() Operation

Sort by

recency

|

459 Discussions

|

  • + 0 comments

    My solution

    e = input("") #English Number
    en = set(input("").split()) #make a set english student
    f = input("") # french number 
    fe = set(input("").split()) # make a set french student
    both = en.intersection((fe)) # set the intersection
    print(len(both)) # How many students are in the both newspaper?
    
  • + 0 comments
    n = int(input())
    set_eng = set(map(int, input().split()))
    
    b = int(input())
    set_fre = set(map(int, input().split()))
    
    final_set = set_eng.intersection(set_fre)
    
    print(len(final_set))
    
  • + 0 comments

    a=input() //If m contains more element than a , It is not occur an error. // this logic only for no of elements not specific no of elements

    m=set([int(i) for i in input().split()]) b=input() n=set([int(i) for i in input().split()]) print(len(m&n))

  • + 0 comments

    Here is HackerRank Set .intersection() Operation in python solution - https://programmingoneonone.com/hackerrank-set-intersection-operation-solution-in-python.html

  • + 0 comments
    m=input()
    l=set(map(int,input().split()))
    n=input()
    s=set(map(int,input().split()))
    print(len(s.intersection(l)))