Delete without head pointer | Must do coding questions for Product Based Companies

Опубликовано: 10 Июль 2026
на канале: Coders by Yutish
293
14

Delete without head pointer

Subscribe to my channel ---    / @codersbyyutish3249  

Link to Ultimate Leetcode Challenge Playlist ---    • #1 Two Sum | Ultimate Leetcode Challenge  

Also checkout my playlist on Coding Interview Problems ---    • Easiest Coding Interview Problem Ever.  ​

---------------------------------------------------------------------------------------------------------------------

Problem Statement:

You are given a pointer/ reference to the node which is to be deleted from the linked list of N nodes. The task is to delete the node. Pointer/ reference to head node is not given.
Note: No head reference is given to you. It is guaranteed that the node to be deleted is not a tail node in the linked list.

Example 1:

Input:
N = 2
value[] = {1,2}
node = 1
Output: 2
Explanation: After deleting 1 from the
linked list, we have remaining nodes
as 2.

Example 2:

Input:
N = 4
value[] = {10,20,4,30}
node = 20
Output: 10 4 30
Explanation: After deleting 20 from
the linked list, we have remaining
nodes as 10, 4 and 30.

Your Task:
You only need to complete the function deleteNode that takes reference to the node that needs to be deleted. The printing is done automatically by the driver code.

Expected Time Complexity : O(1)
Expected Auxilliary Space : O(1)

Constraints:
N = [1, 103]

Link to problem: https://practice.geeksforgeeks.org/pr...

#shorts​ #timeenthusiast