Getting everything ready for you…

Loading courses, problems and your progress. This takes just a moment.

0s

Visualizer › Linked List

Linked List Deletion

Deletes a value: find the node and the one before it, then point the previous node past it.

How it works

Complexity

Code (Python)

def delete(head, value):
    dummy = Node(0, head)
    prev, curr = dummy, head
    while curr:
        if curr.val == value:
            prev.next = curr.next
            break
        prev, curr = curr, curr.next
    return dummy.next

Practise: Linked List problems