Problem 29 of 75

Delete the Middle Node of a Linked List

MediumNot solved yetInterview me on this
Before you code · which pattern fits?

The problem

Given the head of a linked list, delete the middle node (the ⌊n/2⌋-th node, 0-indexed) and return the head of the modified list.

[1,3,4,7,1,2,6] → [1,3,4,1,2,6] [1,2,3,4] → [1,2,4] [2,1] → [2]

Your solution runs against 4 unit tests, including edge and large-value cases.

Loading...

Test console · 4 unit tests

Submit your code to run it against all 4 unit tests. Results appear here.

JavaScript, TypeScript & Python run sandboxed in your browser; other languages run on the execution server. Your code is saved locally as you type.

Hint

Reference solution

Video explanation

Delete the Middle Node of a Linked List, explainedDeepti Talesra