# Problem

problem at: https://leetcode.com/problems/remove-duplicates-from-sorted-list

# Solution

# Mutate the Original List

As the input list is sorted, we can compare curr.va w/ curr.next.val. If same, skip the duplicate; o.w., go to curr.next.

Complexity:

  • time:
  • space:
def deleteDuplicates(self, head: ListNode) -> ListNode:
    curr = head
    while curr and curr.next:
        if curr.val == curr.next.val:
            curr.next = curr.next.next
        else:
            curr = curr.next
    return head