Given two linked list of the same size, the task is to create a new linked list using those linked lists. The condition is that the greater node among both linked list will be added to the new liked list.
Input: list1 = 5->2->3->8 list2 = 1->7->4->5 Output: New list = 5->7->4->8 Input: list1 = 2->8->9->3 list2 = 5->3->6->4 Output: New list = 5->8->9->4
Approach: We traverse both the linked list at the same time and compare node of both lists. The node which is greater among them will be added to the new linked list. We do this for each node.
First List: 5->2->3->8-> Second List: 1->7->4->5-> New List: 5->7->4->8->
- Create a linked list from two linked lists by choosing max element at each position
- Sum of nodes in a linked list which are greater than next node
- Create linked list from a given array
- Swap Kth node from beginning with Kth node from end in a Linked List
- Create a Doubly Linked List from a Ternary Tree
- Remove Nth node from end of the Linked List
- Delete Nth node from the end of the given linked list
- Remove last node of the linked list
- Remove first node of the linked list
- Program for n'th node from the end of a Linked List
- Squareroot(n)-th node in a Linked List
- Linked List | Set 3 (Deleting a node)
- Remove every k-th node of the linked list
- Linked List | Set 2 (Inserting a node)
- Convert singly linked list into circular linked list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.