The first line of the input contains the elements of the singly linked list separated by a single space and terminated by -1. Hence, -1 would never be a list element.
Print a single line containing updated list elements separated by a single space.
You are not required to print the output, it has already been taken care of. Just implement the function.
0 <= N <= 5 * 10^5 -10^9 <= data <= 10^9 and data != -1 Where 'data' is the value of elements that exist in the linked list. Time limit: 1 sec
One fundamental approach will be to check for whether the current element's data already exists ahead in the given linked list or not?
If the current node's data already exists in the list, then we delete the current node. And we go to the next node. We should care about that; our head of the linked list can also be deleted in such a case when the head's data of the given linked list already contains that element. For such a case, We will make a dummy node, and the next node of the dummy node will point to the head of the linked list.
The steps are as follows:-
Deletion In Doubly Linked List
Insertion In Doubly Linked List
Delete Nodes On Regular Intervals
Add One To Linked List