Symmetric Difference

Sort by

recency

|

1219 Discussions

|

  • + 0 comments
    m=int(input())
    a=list(map(int,input().split()))
    a=set(a)
    n=int(input())
    b=list(map(int,input().split()))
    b=set(b)
    c=a.intersection(b)
    d=a.union(b)
    e=d.difference(c)
    e=sorted(e)
    for i in range(len(e)):
        print(e[i],end='\n')
    
  • + 0 comments
    M = int(input())
    set1 = set(map(int, input().split()))
    N = int(input())
    set2 = set(map(int, input().split()))
    symmetric_diff = set1.symmetric_difference(set2)
    symm_list = list(symmetric_diff)
    symm_list.sort()
    for i in symm_list:
        print(i)
    
  • [deleted]
    + 0 comments

    For Python3

    M = int(input())
    A = set(map(int, input().split()))
    N = int(input())
    B = set(map(int, input().split()))
    
    res = sorted(A.symmetric_difference(B))
    
    print(*res, sep="\n")
    
  • + 0 comments
    m = input()
    a = set(map(int, input().split(" ")))
    n = input()
    b = set(map(int, input().split(" ")))
    print(*sorted(a.difference(b).union(b.difference(a))), sep="\n")
    
  • + 0 comments
    m ,set_m, n, set_n = input(), set(map(int, input().split())), input(), set(map(int, input().split()))
    [print(x) for x in sorted(set_m.symmetric_difference(set_n))]