BETA

Difficulty Level: Easy

Submissions: 8535 Accuracy:

43.32%

Remove duplicate element from sorted Linked List (Function Problem)
     

Complete the removeDuplicates() function which takes a list sorted in non-decreasing order and deletes any duplicate nodes from the list. The list should only be traversed once.

For example if the linked list is 11->11->11->21->43->43->60 then removeDuplicates() should convert the list to 11->21->43->60.

Input:
You have to complete the method which takes 1 argument: the head of the  linked list  .You should not read any input from stdin/console. There are multiple test cases. For each test case this method will be called individually.

Output:
Your function should return a pointer to a linked list with no duplicate element.

Constraints:
1<=T<=100
1<=size of linked lists<=50

Note: If you use "Test" or "Expected Output Button" use below example format.

Example:
Input
2
4
2 2 4 5
5
2 2 2 2 2

Output
2 4 5
2



Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Amit Khandelwal, Harshit Sidhwa


					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.