-
Given the pointer to the head node of a doubly linked list, reverse the order of the nodes in place. That is, change the next and prev pointers of the nodes so that the direction of the list is reversed. Return a reference to the head node of the reversed list.
-
Note: The head node might be NULL to indicate that the list is empty.
-
Output format:
- Return a reference to the head of your reversed list. The provided code will print the reverse array as a one line of space-separated integers for each test case.
-
Explanation
- The initial doubly linked list is: 1 <-> 2 <-> 3 <-> 4 --> NULL
- The reversed doubly linked list is: 4 <-> 3 <-> 2 <-> 1 --> NULL