Unique - 30%
Keep the unique elements of the doubly linked list (free others).
There is the following linked list structure:
struct node {
const char *id;
struct node *next;
struct node *prev;
};
Each node is created as part of a doubly linked list. The identifier is allocated on the heap. There are no sentinel nodes. NULL represents an empty list.
Remove all duplicate entries of a doubly linked list (uniq)
struct node * list_unique(struct node *list, struct node **removed, int *removed_count);
Given a doubly linked list, you are to delete any nodes which duplicate the identifier string (id).
For example, if the list contains the sequence A, B, D, A, B, B, C then the resulting list should be A, B, D, C. Nodes of the returned list are presented in the same order they are seen in the original linked list.
The parameter removed is modified by your function to record which node addresses were removed from the original list (even though they are freed). The parameter removed_count is modified by your function to specify how many nodes were removed. You are guaranteed that the size of removed is equal to the length of the linked list. If one node is removed, it is expected that the memory address of removed_count stores a value 1 and that the address of that removed is stored in the array starting at the address removed.
Notes
The case of all identifier strings is guaranteed to be all uppercase, C functions strcmp() , malloc() , free()
You are guaranteed that list, removed , removed_count are never NULL .
You are guaranteed that id in any node is a heap allocated C string and is not NULL.
Helper functions are permitted