<reponame>maanavshah/coding-interview<filename>linked_lists/remove_duplicates_from_linked_list.py
# O(n) time | O(1) space
def removeDuplicatesFromLinkedList(linkedList):
    head = linkedList
    while linkedList:
        if linkedList.next and linkedList.value == linkedList.next.value:
            linkedList.next = linkedList.next.next
        else:
            linkedList = linkedList.next
    return head

# O(n) time | O(1) space
def removeDuplicatesFromLinkedList(linkedList):
    head = linkedList
    while linkedList:
        if linkedList.next and linkedList.value == linkedList.next.value:
            linkedList.next = linkedList.next.next
        else:
            linkedList = linkedList.next
    return head
# O(n) time | O(1) space