DAYS
HOUR
MINS
SEC
Error
Given a sorted doubly linked list and an element X, your need to insert the element X into correct position in the sorted DLL.
Example:
Input: LinkedList:X = 9 Output:
![]()
Your Task:
You only need to complete the function sortedInsert() that takes head reference and x as arguments and returns the head of the modified list. The printing and checking tasks are done by the driver code.
Expected Time Complexity: O(n).
Expected Auxiliary Space: O(1).
Constraints:
1 <= Number of nodes <= 103
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes