Dsa
Linked List
Medium
Remove Duplicates From Sorted Linked List
You are given a sorted linked list where each node contains a value. Your task is to remove all duplicate values from the linked list, ensuring each element appears only once. Implement a function that reads the linked list's elements and prints the modified list in space-separated format.
Input:
The first line contains the integer n, the number of nodes (1 <= n <= 1000).
The second line contains n integers, the values of the nodes in a non-decreasing order.
Output:
Print the elements of the modified linked list in space-separated format without duplicates.
Example:
Input:
5
1 1 2 3 3
Output:
1 2 3
Key concepts
linked_listdeduplication
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