I have a set of elements {1,2,3},{2,3,4},{1,2,4},{7,8},{3,4,7,9},{12,16,18,19}, {1,2,4}.
I need to have a data structure which contains the list above appeared only once. If any new list appears and if it matches any of the existing list then I don't want that to be added to the resulting data structure.
For the above example the expected result should be : {1,2,3},{2,3,4},{1,2,4},{7,8},{3,4,7,9},{12,16,18,19}.
One solution which I am having is to use Trees. For ex: {1,2,3},{1,2,4} In the above list I will branch out for value 3 of 1st list and value 4 of 2nd list from the node which has value 2. In this way I can trace the list from the root and find whether the list appears or not.
Root
|
|
1
|
|
------2------
| |
| |
3 4
Please suggest if is there any algorithm to make it faster and in a simple way using C.