The given singly linked list is 6 -> 5 -> 3 -> 4 -> 7 -> 1 -> 2
The modified linked list should have all even values in starting and odd values in the end.
The first line contains space-separated integers denoting the values of nodes of the Linked List. The Linked List is terminated with -1. Hence, -1 is never a node value of the Linked List.
Print space-separated integers denoting the elements of the modified linked list.
You do not need to print anything; it has already been taken care of. Just implement the given function.
The basic idea is to divide the linked list into two parts - odd and even. The even linked list will contain only nodes whose value is even and vice - versa for the odd linked list. Finally, we will attach the odd linked list after the even linked list.
Algorithm
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Deletion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
Insertion In Doubly Linked List
LRU Cache
Delete Nodes On Regular Intervals
Add One To Linked List