Remove Duplicates from Sorted List
Given the head
of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.
Solutions
Easy solution, compare current item with next item.
Steps
Iterate list item and compare current item with next item.
If both are same then set current next to current node next to next, else set current node to current node next.
Return
head
node.
Time Complexity: O(n)
Auxiliary Space: O(1)
Last updated