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.
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)