Assuming the linked list is 3 -> 2 -> 3 -> 4 -> 2 -> 3 -> NULL.
Number ‘2’ and ‘3’ occurs more than once. Hence we remove the duplicates and keep only their first occurrence. So, our list becomes : 3 -> 2 -> 4 -> NULL.
The first line of input contains an integer ‘T’ representing the number of test cases.
The first and the only line of every test case contains the elements of the linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
For each test case, the resulting linked list is printed.
When multiple nodes have the same element, the node which appeared first is kept, all other duplicates are removed i.e. the order of the nodes should be preserved.
You don’t need to print anything. It has already been taken care of. Just implement the given function.
1 <= T <= 100
1 <= N <= 10 ^ 4
1 <= data <= 10 ^ 5
Where ‘N’ is the number of nodes in the list and 'data' is the value of list nodes.
Time Limit: 1sec
LRU Cache
Longest Subarray With Zero Sum
Maximum GCD
Delete Nodes On Regular Intervals
Add One To Linked List