Problem
You get the head of a linked list. A linked list is a chain of nodes, and each node points to the next node. Delete the middle node, and return the head of the changed list.
For a list of n nodes, the middle node is at index n // 2. The // operator divides and then rounds down to an integer. Indexes start at 0.
For example, a list of 4 nodes has its middle node at index 2. If the list has only one node, the result is an empty list.
Example 1
- Input:
- head = [3,8,1,6,2]
- Output:
- [3,8,6,2]
- Explanation:
- The list has 5 nodes, so the middle node is at index 2. This node has the value 1.
Example 2
- Input:
- head = [5,7,7,5]
- Output:
- [5,7,5]
- Explanation:
- The list has 4 nodes, so the middle node is at index 2.
Example 3
- Input:
- head = [6]
- Output:
- []
- Explanation:
- The only node is the middle node. After the deletion, the list is empty.
Constraints
- The number of nodes is in the range [1, 10^5].
- 1 <= Node.val <= 10^5
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2095. Delete the Middle Node of a Linked List
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source