VOOZH about

URL: https://www.geeksforgeeks.org/dsa/remove-first-node-of-the-linked-list/

⇱ Deletion at beginning (Removal of first node) in a Linked List - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Deletion at beginning (Removal of first node) in a Linked List

Last Updated : 21 Oct, 2025

Given a head of the linked list, we need to remove the first node from the given linked list.

Examples:

Input :

👁 blobid2_1755951985

Output : 2 -> 3 -> 1 -> 7 -> NULL
Explanation: After deleting head from the given linked list, we'll be left with just 2 -> 3 -> 1 -> 7.

👁 blobid3_1755951992


Input :

👁 blobid0_1755949645

Output : 5 -> 7 -> 8 -> 99 -> 100 -> NULL
Explanation: After deleting head from the given linked list, we'll be left with just 5 -> 7 -> 8 -> 99 -> 100.

👁 blobid1_1755949657

By Shifting head node to next node of head - O(1) Time and O(1) Space

To remove the first node of a linked list, store the current head in a temporary variable (temp), move the head pointer to the next node, delete the temporary head node and finally , return the new head of the linked list.


Below is the implementation of the above approach:


Output
2 -> 3 -> 1 -> 7

Time Complexity: O(1), because the operation to delete the head node is performed in constant time.
Space Complexity: O(1)

Comment