You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: DSA Crack Sheet/README.md
+1
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,7 @@
155
155
-[Clone a linked list with next and random pointer](https://practice.geeksforgeeks.org/problems/clone-a-linked-list-with-next-and-random-pointer/1#"view question") - [Cpp Solution](./solutions/Clone%20a%20linked%20list%20with%20next%20and%20random%20pointer.cpp)
156
156
-[Merge K sorted linked lists](https://practice.geeksforgeeks.org/problems/merge-k-sorted-linked-lists/1#"view question") - [Cpp Solution](./solutions/Merge%20K%20sorted%20linked%20lists.cpp)
157
157
-[Multiply two linked lists](https://practice.geeksforgeeks.org/problems/multiply-two-linked-lists/1#"view question") - [Cpp Solution](./solutions/Multiply%20two%20linked%20lists.cpp)
158
+
-[Delete nodes having greater value on right](https://practice.geeksforgeeks.org/problems/delete-nodes-having-greater-value-on-right/1#"view question") - [Cpp Solution](./solutions/Delete%20nodes%20having%20greater%20value%20on%20right.cpp)
Given a singly linked list, remove all the nodes which have a greater value on its following nodes.
6
+
7
+
Example 1:
8
+
Input:
9
+
LinkedList = 12->15->10->11->5->6->2->3
10
+
Output: 15 11 6 3
11
+
Explanation: Since, 12, 10, 5 and 2 are
12
+
the elements which have greater elements
13
+
on their next node. So, after deleting
14
+
them, the linked list would like be 15,
15
+
11, 6, 3.
16
+
17
+
Example 2:
18
+
Input:
19
+
LinkedList = 10->20->30->40->50->60
20
+
Output: 60
21
+
Your Task:
22
+
The task is to complete the function compute() which should modify the list as required and return the head of the modified linked list. The printing is done by the driver code,
23
+
24
+
Expected Time Complexity: O(N)
25
+
Expected Auxiliary Space: O(1)
26
+
27
+
Constraints:
28
+
1 <= size of linked list <= 1000
29
+
1 <= element of linked list <= 1000
30
+
Note: Try to solve the problem without using any extra space.
0 commit comments