We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Here is a easy solution. If you have any question just ask. :)
Node*Reverse(Node*head){Node*temp;Node*itr=head;while(itr){temp=itr->next;//reserve the nextitr->next=itr->prev;//swap prev and nextitr->prev=temp;head=itr;//we do not know if there is a next element itr=temp;//iterate to next}returnhead;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a doubly linked list
You are viewing a single comment's thread. Return to all comments →
Here is a easy solution. If you have any question just ask. :)