# How to find the disjunction of two unique lists in C

So if first list is 3, 6, 4, 5 And the second 6, 5, 7 The disjunction between two lists is 3,4,7

My idea was to compare all nodes from first list with all of them from second, so:

Comparing 3 to 5,6,7 and if neither is matched make a node in new list with value 3. But as the list goes on, when I compare the last node (5) with all other nodes in second that's the end of function, and the number 7 is missing from the disjucntion. Thats the problem.

Think about how you would do it in real life. If you had a set of 7 cards with numbers on them and one had {3, 4, 5, 6} and the other had {5, 6, 7} how do you go about finding the disjunction?

This might be a bit simple and not optimized but I would personally start out 'assuming' every element is in the disjunction.

Pseudocode:

Create a set of all the elements used at least once
making sure to have no duplicate elements in the set.
//In this particular problem: initial disjunctive array = {3, 4, 5, 6, 7}

For every element 'first' in the first set of cards:
For every element 'second' in the second set of cards:
If (first == second && first is still in the disjunctive array)
Remove first from the disjunctive array

By removing all elements from the array that appear in both sets, you end up with the disjunction.