My issue
Remove Duplicates from Sorted List
You are given head of the non-empty sorted linked list where the value of the
�
�
ℎ
i
th
node will be
�
�
A
i
.
Your task is to delete all duplicates such that each element appears only once and return the linked list sorted.
Input:
First line will contain
�
T, number of test cases. Then the test cases follow.
The first line contains one integer
�
N — the length of the linked list.
The second line contains
�
N space separated integers
�
1
,
�
2
,
…
�
�
A
1
,A
2
,…A
N
— the value of the linked list nodes starting from the head for the linked list.
Note:
For Java language, you need to:
Complete the function in the submit solution tab:
Node removeDuplicates(Node head){…}
For C++ language, you need to:
Complete the function in the submit solution tab:
Node* removeDuplicates(Node* head){…}
For Python language, you need to:
Complete the function in the submit solution tab:
def Node removeDuplicates(self, head):
Output:
The function you complete should return the required answer.
Constraints
1
≤
�
≤
10
1≤T≤10
1
≤
�
,
�
�
≤
1
0
5
1≤N,A
i
≤10
5
Sample 1:
Input
Output
3
5
1 1 6 8 8
5
1 2 3 4 5
4
5 5 5 5
1 6 8
1 2 3 4 5
5
My code
'''
# Node Class:
class Node:
def init(self,val):
self.data = val
self.next = None
'''
class Solution:
def removeDuplicates(self, head):
# code here
Learning course: Placement preparation for Product companies
Problem Link: Remove Duplicates from Sorted List Practice Problem in Placement preparation for Product companies - CodeChef