Drop the Nth Most Recent Notification From a Linked Feed

Last updated: November 29, 2026

Quick Overview

Given the head of a singly linked list of notifications (oldest first) and n, remove the nth node from the end in a single pass and return the new head.

Meta
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given the head of a singly linked list of notifications (oldest first) and n, remove the nth node from the end in a single pass and return the new head.

A Meta phone-screen Easy framed as retracting a specific recent notification from a linked in-memory feed. The interviewer checks for the gap-of-n two-pointer technique and a dummy node so that removing the head is not a special case.

What the Interviewer Expects
  • Use a dummy node before head
  • Advance a lead pointer n steps ahead
  • Move both pointers until the lead reaches the last node
  • Unlink the target node
  • Explain one-pass versus two-pass trade-off
Key Topics to Cover
Linked list
Two pointers
Dummy node
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
  • Remove every kth node from the end.
  • What if n can exceed the list length?
  • Do it for a doubly linked list where you have a pointer to the tail.
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: head of a list of length L >= 1 and 1 <= n <= L. Output: head after deleting the node at position L - n (0-based from the front). The interviewer asks for one pass, so we should not count t...

High-Level Design

Place dummy before head and set both lead and trail to dummy. Move lead forward n steps; now there are exactly n nodes between trail's next and lead inclusive. Advance both together until `lea...


Submit Your Answer
Markdown supported