Delete Head of Doubly Linked List

easy

Given the head of a doubly linked list, remove the first node and return the head of the resulting list.

Each node stores an integer val and two links: prev (the node before it) and next (the node after it). Deleting the head means the second node becomes the new head — and because it is now first, its prev link must point to nothing.

Return the new head. If the list becomes empty, return the empty list (a null head).

Hints

You do not need to move most of the list at all — only the very front changes.
Who becomes the new head, and what one link on that node is now a lie?
The new head is head.next; because the list is doubly linked, clear its prev before returning.

Common doubts

In a doubly linked list the new head still stores a prev pointer aimed at the deleted node. If you leave it, the list is inconsistent — walking backward from the head would re-enter a node that no longer belongs.
Return a null head. Deleting the only node of a one-element list leaves nothing, so the correct result is an empty list, not a dangling node.
In languages with manual memory (like C++) you can delete it to avoid a leak; in garbage-collected languages it is reclaimed once nothing references it. Either way, unlink it first.

Interview follow-ups

Symmetric: the new tail is tail.prev, and you set newTail.next = null. Because it is doubly linked you reach the last node in O(n) by walking, or O(1) if a tail pointer is maintained.
Splice it out by connecting its neighbours: node.prev.next = node.next and node.next.prev = node.prev, guarding the boundary cases where prev or next is null.

Fun facts

  • The prev pointer is exactly why doubly linked lists let you delete a known node in O(1) without first hunting for its predecessor — something a singly linked list cannot do.
  • This two-pointer rewiring is the same move that powers LRU caches, where the most recently used node is constantly detached and re-inserted at the front.

Asked at

AmazonMicrosoftAdobe
Frequently Sometimes Occasionally
Example 1
Input: head = [1, 2, 3]
Output: 2 <-> 3
The first node 1 is removed, and node 2 becomes the new head with its prev pointing to nothing.
Example 2
Input: head = [2, 5, 7, 8, 99, 100]
Output: 5 <-> 7 <-> 8 <-> 99 <-> 100
The head node 2 is deleted, and the remaining list starts from node 5.
Constraints

- 2 <= number of nodes <= 10^5 - 1 <= node.val <= 10^9

Solve this problem →