Delete Middle Node

LINKED LIST

### Problem

Given the `head`

of a singly linked list, remove the middle node of the list and return the head of the modified list.

If the list has an even number of nodes, remove the second of the two middle nodes.

### Examples

`deleteMiddle([1,2,3,4,5]); // returns [1,2,4,5] // The middle node is 3, then 3 is deleted from the list deleteMiddle([1,2,3,4]); // returns [1,2,4] // When the list has an even number of elements // the second middle node (3) is removed.`

Loading...

1

2

3

4

5