Skip to content

#2095 - Delete the Middle Node of a Linked List

MediumLinked List
Open on LeetCode

Given the head of a linked list, delete the middle node and return the modified head. The middle node is the ⌊n / 2⌋-th node (0-indexed), where n is the list length. If the list has one node, return null.

InputOutput
[1,3,4,7,1,2,6][1,3,4,1,2,6] (removed node 7 at index 3)
[1,2,3,4][1,2,4] (removed node 3 at index 2)
[2,1][2] (removed node 1 at index 1)

Released under the MIT License.