You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the floor(n / 2)th node from the start using 0-based indexing. For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.
You are given the head of a linked list. Delete the middle node, and return the head of the modified linked list. The middle node of a linked list of size n is the floor(n / 2)th node from the start using 0-based indexing. For n = 1, 2, 3, 4, and 5, the middle nodes are 0, 1, 1, 2, and 2, respectively.
Example 1:
Input: {"head":[1,3,4,7,1,2,6]}
Output: [1,3,4,1,2,6]
Constraints:
The number of nodes in the list is in the range [1,105].
1≤Node.val≤105
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"head":[1,3,4,7,1,2,6]}
The list has 7 nodes, so the middle is index floor(7 / 2) = 3. To unlink it we need the node just before it.