Beta

Operations on Sets: Symmetric Difference

Description:

In mathematics, a set is a collection of distinct numbers. The symmetric difference of two sets is the set of elements which are in either of the sets and not in their intersection.

Symmetric Difference

Symmetric Difference of a and b (a△b) marked in gray

Your taks is to implement method getSymmetricDifference which takes two sets of unique integer values and returns symmetric difference of these sets.

Examples:

  a = {2, 3, 7, 8}
  b = {5, 6, 2, 4, 7}
  a△b = {3, 8, 5, 6, 4}
  
  a = {3, 4, 2, 5, 7, 9}
  b = {1, 9, 8}
  a△b = {3, 4, 2, 5, 7, 1, 8}
  
  a = {13, 255, 354, 211, 120}
  b = {255, 354, 211, 120, 13}
  a△b = {}
  
  // If any of sets are empty method should return another set
  a = {}
  b = {5, 6, 2, 4, 7}
  a△b = {5, 6, 2, 4, 7}
  
  // If both sets are empty method should return empty set
  a = {}
  b = {}
  a△b = {}
  

Note: Method should return null if any of the arguments is null

Algorithms
Mathematics
Sets

Stats:

CreatedApr 22, 2016
PublishedApr 22, 2016
Warriors Trained96
Total Skips13
Total Code Submissions225
Total Times Completed40
Java Completions40
Total Stars2
% of votes with a positive feedback rating95% of 19
Total "Very Satisfied" Votes17
Total "Somewhat Satisfied" Votes2
Total "Not Satisfied" Votes0
Total Rank Assessments22
Average Assessed Rank
7 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • Saka7 Avatar
Ad