Given a singly linked list, the task is to remove all the nodes which have a greater value on left side.
Input: 12->15->10->11->5->6->2->3 Output: Modified Linked List = 12 15 Input: 25->15->6->48->12->5->16->14 Output: Modified Linked List = 14 16 48
- Initialize the maximum with head node.
- Traverse the list.
- Check if the next node is greater than max_node then update the value of max_node and move to the next node.
- Else delete the next node.
Below is the implementation of above approach:
Given Linked List 12 15 10 11 5 6 2 3 Modified Linked List 12 15
- Delete all the nodes from the doubly linked list that are greater than a given value
- LinkedList in Java
- Address Calculation Sort using Hashing
- Delete every Kth node from circular linked list
- Delete all the nodes from the list which are less than K
- Iterative Merge Sort for Linked List
- Recursively Reversing a linked list (A simple implementation)
- Sum of the nodes of a Singly Linked List
- Segregate even and odd nodes in a Linked List using Deque
- Insertion at Specific Position in a Circular Doubly Linked List
- Reverse a doubly circular linked list
- Recursive Approach to find nth node from the end in the linked list
- Implementing a Linked List in Java using Class
- Find kth node from Middle towards Head of a Linked List
- Count pairs in a binary tree whose sum is equal to a given value x
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.