Dsa
Linked List
Easy
Remove Duplicates from Sorted Linked List
Given a sorted linked list, delete all duplicates such that each element appears only once. You must do this in-place and should not use any extra space for an additional data structure.
Input format:
- The first line contains an integer n, the number of nodes in the list.
- The second line contains n integers, the node values of the list (sorted).
Output format:
- Print the modified list as space-separated integers.
Example:
Input:
5
1 1 2 3 3
Output:
1 2 3
Key concepts
linked_listdeduplicationsorting
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