Symmetric Difference

Sort by

recency

|

1209 Discussions

|

  • + 0 comments

    def sym_diff(): s1=input() a=input() a1=a.split(" ") set1={int(i) for i in a1} s2=input() b=input() a2=b.split(" ") set2={int(i) for i in a2} return sorted(set1-set2| set2 - set1) op=sym_diff() for i in op: print(i)

  • + 0 comments
    m = int(input())
    setM = set(map(int, input().split()))
    
    n = int(input())
    setN = set(map(int, input().split()))
    
    print(*sorted(setM ^ setN), sep="\n")
    
  • + 0 comments
    n = int(input())
    a = set()
    a_initial_value = []
    a_initial_value = list(map(int, input().split()))
    for i in range(n):
        a.add(a_initial_value[i])
    
    m = int(input())
    b = set()
    b_initial_value = []
    b_initial_value = list(map(int, input().split()))
    for j in range(m):
        b.add(b_initial_value[j])
    
    
    a_difference = a.difference(b)
    b_difference = b.difference(a)
    ab_union = a_difference.union(b_difference)
    
    
    ab_union = list(ab_union)
    
    ab_union.sort()
    
    for k in ab_union:
        print(k)
    
  • + 0 comments
    n=int(input())
    set1=set(map(int, input().split()[:n]))
    m=int(input())
    set2=set(map(int, input().split()[:m]))
    result=sorted(set1^set2)
    for i in result:
        print(i)
    
  • + 0 comments

    m = int(input())

    a = set(map(int, input().split()[:m]))

    n = int(input())

    b = set(map(int, input().split()[:n]))

    result = a ^ b

    for item in sorted(result):

    print(item)