HackerRank Python- Symmetric Difference

Given 2 sets of integers, M and N, print their symmetric difference in ascending order. The term symmetric difference indicates those values that exist in either M or N but do not exist in both.

  1. # Enter your code here. Read input from STDIN. Print output to STDOUT
  2. if __name__ == "__main__":
  3. M = int(input().strip())
  4. set_m = set(map(int, input().strip().split(' ')))
  5. N = int(input().strip())
  6. set_n = set(map(int, input().strip().split(' ')))
  7. for el in sorted(set_m ^ set_n):
  8. print(el)


Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube