//*******************************************************************
//Code Curtesy of Jonathan Vargas - Sayuga Solutions
//email: jvargas.sayuga@gmail.com
//
//Description: takes two int arrays and returns a list of only unique
//extra values that are present in only one of the lists at a time
//*******************************************************************
import java.util.*;
public class myTools {
public static void main(String[] args){
int[] x = {15, 27, 1, 4, 2, 50, 3, 1};
int[] y = {2, 4, -4, 3, 1, 1, 14, 27, 50};
myTools tool = new myTools();
Set<Integer> result = new HashSet<>(tool.uniqueExtras(x, y));
System.out.print(result);
}
public static List<Integer> intArrayToList( int[] k){
List<Integer> s = new ArrayList<Integer>();
for (int r: k)
{
s.add(r);
}
return s;
}
public static List<Integer> findExtras( List<Integer> e, List<Integer> x){
List<Integer> z = new ArrayList<Integer>();
for(Integer q:e){
if (!x.contains(q)){
z.add(q);
}
}
return z;
}
public static Set<Integer> uniqueExtras(int[] a, int[] b) {
myTools tool = new myTools();
List<Integer> output = new ArrayList<Integer>();
List<Integer> x = tool.intArrayToList(a);
List<Integer> y = tool.intArrayToList(b);
output.addAll(0, tool.findExtras(x, y));
output.addAll(0, tool.findExtras(y, x));
Set<Integer> result = new HashSet<>(output);
return result;
}
}