Given an unsorted linked list of N nodes. The task is to remove duplicate elements from this unsorted Linked List. If all the nodes in the linked list are equal, then remove n-1 nodes.
First line of input contains number of testcases T. For each testcases, first line of input contains number of nodes in the linked list, and next line contains node data for N nodes.
For each testcase, print the linked list with no repeating elements.
You have to complete the method removeDuplicates() which takes 1 argument: the head of the linked list .You should not read any input from stdin/console. Your function should return a pointer to a linked list with no duplicate element.
1 <=T<= 100
1 <= size of linked lists <= 50
5 2 2 4
2 2 2 2 2
5 2 4
Testcase 1: Given linked list elements are 5->2->2->4, in which 2 is repeated only. So, we will delete the extra repeated elements 2 from the linked list and the resultant linked list will contain 5->2->4.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.