Delete the Middle Node of a Linked List
Medium
Topics
Given the head of a linked list, delete the middle node (the node at 0-indexed position floor(n/2)) and return the head. If the list has one node, return an empty list.
Example 1
Input: head = [1,3,4,7,1,2,6] Output: [1,3,4,1,2,6]
Example 2
Input: head = [1,2,3,4] Output: [1,2,4]
Constraints
- 1 <= number of nodes <= 10^5
- 1 <= Node.val <= 10^5
Run ⌘' · Submit ⌘⏎