601. Reverse a Doubly Linked List
You are given the head of a doubly linked list.
Reverse the list in-place and return the new head of the reversed list.
Example 1:
Input: head = [10, 20, 30]
Output: [30, 20, 10]
Example 2:
Input: head = [1, 3, 5, 7, 9]
Output: [9, 7, 5, 3, 1]
Now Your Turn!
Pick the correct output for the given inputInput: head = [42]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= number of nodes <= 106
- 0 <= node.val <= 104