Delete a Node When You Hold Only a Pointer to It

Last updated: November 29, 2026

Quick Overview

You are given a pointer to a node in a singly linked list of cache entries, guaranteed not to be the tail, and no access to the head. Remove that node's entry from the list.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Easy

0

0

0 solved


You are given a pointer to a node in a singly linked list of cache entries, guaranteed not to be the tail, and no access to the head. Remove that node's entry from the list.

A Google technical screen brain teaser used to see whether a candidate can reframe a problem when the usual approach (find the predecessor) is impossible. The interviewer then pushes on the consequences of the trick, which is where the real signal is.

What the Interviewer Expects
  • Recognize the predecessor cannot be reached
  • Copy the successor's value into this node and unlink the successor
  • Explain why the tail cannot be deleted this way
  • Call out that external references to the successor node become stale
  • State O(1) time and space
Key Topics to Cover
linked list
node deletion
aliasing
constraints reasoning
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What breaks if another component holds a pointer to the successor node?
  • How would a doubly linked list change this?
  • Could you delete the tail if you were allowed a sentinel tail node?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: node, an interior node (not the tail).
  • Effect: the list, read from its head, no longer contains node's original value.
  • No head pointer; O(1) work....
High-Level Design

Without the head you cannot find the predecessor, so you cannot change the pointer that leads into this node. Instead, make this node become its successor: copy the successor's payload over, then bypa...


Submit Your Answer
Markdown supported