Remove Duplicates from Sorted DLL
Medium Problems of Doubly Linked List DSA practice problem on Onlearn.
Difficulty: medium.
Topics: How do you remove duplicates from a sorted doubly linked list (DLL)?, Doubly Linked List, Linked List, Node, Pointer, Algorithm, in-place algorithms, pointer operations, duplicate handling, data structures, linked list, Data Structures, In-Place Algorithms.
Problem Statement Given the head of a sorted Doubly Linked List, delete all duplicate nodes such that each element appears only once. The resulting list should also be sorted. A Doubly Linked List (DLL) is a type of linked list in which each node has two pointers, next and prev. The next pointer points to the subsequent node, and the prev pointer points to the preceding node. The head node's prev pointer and the tail node's next pointer are typically None. Input The head of the sorted Doubly Linked List. Output The head of the modified Doubly Linked List with duplicates removed. Constraints The number of nodes in the list is in the range [0, 1000]. 100 <= Node.val <= 100 The list is guaranteed to be sorted in non decreasing order. Sample Test Cases Sample Input 1: Sample Output 1: Explanation: The original list contains duplicate values (1, 3). After removing duplicates, each value appears only once, and the list remains sorted.