head of a singly linked list with n nodes. Remove its middle node and return the head of the resulting list.
The middle node is the one at 0-based index n // 2. For example, for n = 1, 2, 3, 4, 5 that is index 0, 1, 1, 2, 2 respectively.
Try to do it in a single pass over the list.head=list_node([6, 2, 9, 4, 1]) → [6, 2, 4, 1]
The list has 5 nodes, so the middle one is at index 5 // 2 = 2, the value 9.
head=list_node([3, 8, 5, 7]) → [3, 8, 7]
With 4 nodes, the middle is index 4 // 2 = 2, the value 5.
head=list_node([11]) → None
The only node is the middle one; removing it leaves an empty list.
head=list_node([6, 2, 9, 4, 1])
[6, 2, 4, 1]
Run checks the first 3 tests in your browser. Submit checks all 57 tests on the server, hidden ones included.