Symmetric Difference

Sort by

recency

|

1221 Discussions

|

  • + 0 comments
    1. M = input()
    2. N = set(map(int,input().split()))
    3. O = int(input())
    4. P = set(map(int,input().split()))
    5. not_common = N ^ P
    6. li = sorted(not_common)
    7. for i in li:
    8. print(i)
  • + 0 comments
    def diff_set(a, b):
        # (a.difference(b)).union(b.difference(a)) == a.symmetric_difference(b)
        sorted_list = sorted(a.symmetric_difference(b))   
        for i in (sorted_list):
            print(i)
        return 0
    
    if __name__ =='__main__':
        M = int(input())
        a = set(map(int,input().split()))
        N = int(input())
        b = set(map(int,input().split()))
        diff_set(a, b)
    
  • + 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")