An Expedia itinerary is represented as a singly linked list of activity identifiers. Remove every duplicate value from the list while preserving the order of the first occurrence. Modify the existing list in place and return the updated head.
Use the following node representation:
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
Implement remove_duplicates(head). The input list may be unsorted. For test cases, lists are shown as arrays of node values, and the expected result is also shown as an array. The test harness converts these arrays to and from linked lists.
def remove_duplicates(head):