We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
You are given the pointer to the head node of a sorted linked list, where the data in the nodes is in ascending order. Delete nodes and return a sorted list with each distinct value in the original list. The given head pointer may be null indicating that the list is empty.
Example
refers to the first node in the list .
Remove 1 of the data values and return pointing to the revised list .
Function Description
Complete the removeDuplicates function in the editor below.
removeDuplicates has the following parameter:
SinglyLinkedListNode pointer head: a reference to the head of the list
Returns
SinglyLinkedListNode pointer: a reference to the head of the revised list
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Delete duplicate-value nodes from a sorted linked list
You are viewing a single comment's thread. Return to all comments →
You are given the pointer to the head node of a sorted linked list, where the data in the nodes is in ascending order. Delete nodes and return a sorted list with each distinct value in the original list. The given head pointer may be null indicating that the list is empty.
Example
refers to the first node in the list .
Remove 1 of the data values and return pointing to the revised list .
Function Description
Complete the removeDuplicates function in the editor below.
removeDuplicates has the following parameter:
SinglyLinkedListNode pointer head: a reference to the head of the list Returns
SinglyLinkedListNode pointer: a reference to the head of the revised list