


A doubly linked list is a kind of linked list that is bidirectional, meaning it can be traversed in both forward and backward directions.
Input:
4
4 3 2 1
This means you have been given doubly linked list of size 4 = 4 <-> 3 <-> 2 <-> 1.
Output:
1 2 3 4
This means after reversing the doubly linked list it becomes 1 <-> 2 <-> 3 <-> 4.
The first line contains an integer 'N', the size of the linked list.
The second line contains 'N' space-separated integers.
The output contains all the integers of the reversed doubly linked list.
You don’t need to print anything. Just implement the given function.
The idea is to use recursion and the given function will iterate the doubly linked list in the previous direction by calling itself recursively to reverse it.
Base condition = If the node is NULL then return NULL.
Recursive calls = Swap the next and prev pointers.
The idea is to swap next and prev pointers between every two consecutive nodes. And in last making the last node as head and return it.