Dsa
Linked List
Warm-up
Remove Duplicates from Sorted List
Given a linked list containing only integers sorted in non-decreasing order, your task is to remove any duplicate elements and return the modified linked list with only distinct values. The linked list nodes are represented as space-separated integers followed by -1.
Input format:
- A single line containing integers representing the linked list followed by -1.
Output format:
- A single line of space-separated integers representing the linked list with duplicates removed.
Example:
Input:
1 1 2 3 3 -1
Output:
1 2 3
Key concepts
linked_listduplicatestraversal
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now