Set .union() Operation

Sort by

recency

|

764 Discussions

|

  • + 0 comments

    s= int(input()) set1=set(map(int,input().split(" "))) a= int(input()) set2=set(map(int,input().split(" "))) print(len(set1| set2))

  • + 0 comments

    i1 = int(input()) l1 = set(input().split()) i2 = int(input()) l2 = set(input().split())

    print(len(l1.union(l2)))

  • + 0 comments

    n = int(input()) students = set(map(int, input().split())) b = int(input()) be = set(map(int, input().split()))

    print(len(students | be))

  • + 0 comments
    n = int(input())
    nE = set(map(int, input().split()))
    
    b = int(input())
    bF = set(map(int, input().split()))
    
    print(len(nE | bF))
    
  • + 0 comments

    Here's my code:

    el = int(input())
    e = set(list(map(int, input().split()))[:el])
    fl = int(input())
    f = set(list(map(int, input().split()))[:fl])
    print(len(e.union(f)))