Рет қаралды 97
Given a sorted linked list, delete all nodes that have duplicate numbers (all occurrences), leaving only numbers that appear once in the original list, and return the head of the modified linked list.
Examples:
Input: Linked List = 23-28-28-35-49-49-53-53
Output: 23 35
Explanation:
The duplicate numbers are 28, 49 and 53 which are removed from the list.
Input: Linked List = 11-11-11-11-75-75
Output: Empty list
Explanation:
All the nodes in the linked list have duplicates. Hence the resultant list would be empty.
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Table of Contents
0:00 Problem Statement
0:50 Solution
8:50 Solution - Example
14:15 Pseudo Code
17:33 Python Code
18:55 C++ Code