30 Day code challenge-python
Day 24— More Linked Lists
Task
A Node class is provided for you in the editor. A Node object has an integer data field, data, and a Node instance pointer, next, pointing to another node (i.e.: the next node in a list).
A removeDuplicates function is declared in your editor, which takes a pointer to the head node of a linked list as a parameter. Complete removeDuplicates so that it deletes any duplicate nodes from the list and returns the head of the updated list.
Input Format
The first line contains an integer, N, the number of nodes to be inserted.
The N subsequent lines each contain an integer describing the data value of a node being inserted at the list’s tail.
Output Format
Your removeDuplicates function should return the head of the updated linked list. The locked stub code in your editor will print the returned list to stdout.
Explanation
Line 31–36: Gets input from the user and calls class function insert.
Line 5–17: Inserts value to the nodes.
Line 37: Calls the class function removeDuplicates.
Line 24–30: Removes duplicate values from the nodes.
Line 38: Calls the display function.
Line 18–22: Prints the data of Linked List.
Bonus Tip: Similarly we can also remove duplicate items from doubly linked list.
See you on day 25