Delete a Non-Tail Value through Its Supplied Node

Quick Overview

Delete a Non-Tail Value through Its Supplied Node. You receive only the node to delete from a singly linked list, not the head. The node is not the tail. Remove its value, reduce the list length by one, and pres

Delete a Non-Tail Value through Its Supplied Node

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Other

### Problem You receive only the node to delete from a singly linked list, not the head. The node is not the tail. Remove its value, reduce the list length by one, and preserve the value order before and after that position. The source does not require freeing a particular memory object. Keep the original void deleteNode(ListNode*) interface. ```cpp void deleteNode(ListNode* node); ``` ### Examples ```text original list [6,2,9,4], supplied node has value 2 -> list becomes [6,9,4] original list [1,8], supplied node has value 1 -> list becomes [8] ``` ### Constraints - The chain has 2 through 1000 nodes with unique values in [-1000,1000]. - The supplied node belongs to it and is not its final node.

Overview: Delete a Non-Tail Value through Its Supplied Node. You receive only the node to delete from a singly linked list, not the head. The node is not the tail. Remove its value, reduce the list length by one, and pres

Meta logo
Meta
Sep 28, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0

Problem

You receive only the node to delete from a singly linked list, not the head. The node is not the tail. Remove its value, reduce the list length by one, and preserve the value order before and after that position. The source does not require freeing a particular memory object. Keep the original void deleteNode(ListNode*) interface.

void deleteNode(ListNode* node);

Examples

original list [6,2,9,4], supplied node has value 2 -> list becomes [6,9,4]
original list [1,8], supplied node has value 1 -> list becomes [8]

Constraints

  • The chain has 2 through 1000 nodes with unique values in [-1000,1000].
  • The supplied node belongs to it and is not its final node.