Delete the Middle Node of a Linked List
MediumLinked List
Decode it first. Clues, constraints, pattern and plan before any code.You get the head of a linked list with n nodes. Delete the middle node, the one at 0-based index n // 2 (round down), and return the head of the changed list. With an even count that is the second of the two middle nodes. If the list has only one node, deleting it leaves an empty list.
1 -> 3 -> 4 -> 7 -> 1 -> 2 -> 6 → 1 -> 3 -> 4 -> 1 -> 2 -> 6 (index 3 removed)
1 -> 2 -> 3 -> 4 → 1 -> 2 -> 4 (index 2 removed)
2 -> 1 → 2Return None (null in TypeScript) when nothing is left.
Constraints
1 <= number of nodes <= 10^51 <= Node.val <= 10^5