Set .intersection() Operation

Sort by

recency

|

464 Discussions

|

  • + 0 comments
    n = int(input())
    a = set(map(int,input().split()))
    m = int(input())
    b = set(map(int,input().split()))
    print(len(a&b))
    
  • + 0 comments

    N=int(input()) # english newspaper English=set(map(int,input().split()))

    N1=int(input()) # french newspaper French=set(map(int,input().split()))

    '''Common_subscription=English.intersection(French) print(len(Common_subscription))'''

    YOU CAN ALSO USE THIS

    METHOD

    print(len(English.intersection(French)))

  • + 0 comments
    n=int(input())
    n_roll=set(map(int,input().split()))
    b=int(input())
    b_roll=set(map(int,input().split()))
    print(len(n_roll&b_roll))
    
  • + 0 comments

    a,n,b,m=int(input()), set(input().split()), int(input()), set(input().split())

    print(len(n.intersection(m)))

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    n = int(input())
    eng = set(map(int,input().split()))
    b = int(input())
    fren = set(map(int,input().split()))
    print (len(eng.intersection(fren)))