← 返回 amazon 的题目列表Linked List Manipulation
类型:online_judge
amazon
Given a singly linked list, reverse the list starting from the middle and return the new head node. Assume the number of nodes in the list is odd. The input is the head node of the list, and the output is the new head node. Implement with $O(n)$ time complexity and $O(1)$ space complexity. Example input: 1 -> 2 -> 3 -> 4 -> 5, example output: 1 -> 2 -> 5 -> 4 -> 3.
Example
Input
1 2 3 4 5