Given the head of a linked list whose values are already in nondecreasing order, delete repeated nodes so that every remaining value occurs exactly once. You may visit each node no more than one time, and you are allowed to update the list's head pointer. Create a function that receives the linked-list head and returns the head of the list after duplicates have been removed.
Input: 2->2->4->5->5
Output: 2->4->5
The duplicate occurrences of 2 and 5 are discarded, leaving one node for each distinct value.