Remove Duplicates from Sorted List II Problem

Remove Duplicates from Sorted List II Problem — ExecCode Easy DSA Practice

Solve the Remove Duplicates from Sorted List II problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Your task is to compute the required answer and return the linked list sorted as well.

Examples

Input {"values": [1, 2, 3, 3, 4]}; Output 1 2 4. Input {"values": [1, 1, 1, 2, 3]}; Output 2 3. Input {"values": [1, 2, 2, 3, 4, 4, 5]}; Output 1 3 5

Constraints

The number of nodes in the list is in the range [0, 300]. -100 <= Node.val <= 100 The list is guaranteed to be sorted in ascending order.

Practice Remove Duplicates from Sorted List II free on ExecCode. Browse DSA problems, topic map, and placement guides.