Remove Duplicates from Sorted Linked List
Easyjavapythonccppjavascript
Given a sorted linked list, remove nodes with repeated values so that every value appears only once.
Input Format
The first line contains an integer N. The second line contains N space-separated integers in non-decreasing order.
Output Format
Print the list after removing duplicates, separated by single spaces.
Example 1
Input
5 1 1 2 3 3
Output
1 2 3
Explanation: Repeated adjacent values are reduced to a single node.
- 1 <= N <= 100000
- -1000000000 <= value <= 1000000000