Problem Statement
This challenge is part of a tutorial track by MyCodeSchoolYou’re given the pointer to the head node of a doubly linked list. Reverse the order of the nodes in the list. The head node might be NULL to indicate that the list is empty.
Source Code:
** The above solution is my own code and it may not be the optimal solution or optimal way to approach the problem but it passes all the testcases in Hackerrank. So if you have any optimal approaches feel free to paste the code as the comment below..... :) :) :)/* Reverse a doubly linked list, input list may also be empty Node is defined as struct Node { int data; Node *next; Node *prev; } */ Node* Reverse(Node* head) { Node *cur = head,*temp = new Node; // Complete this function // Do not write the main method. while(cur !=NULL){ temp->next = cur->next; temp->prev = cur->prev; cur->next = temp->prev; cur->prev = temp->next; cur = temp->next; if(cur!=NULL){ head = cur; } } return head; }
Our writing service is dedicating the excellent writing process and programs in online. The high volume of writing is possible in our writing service. You can manage your writing papers by the experts. The learning guide to be provide for the experts to the students.The essay writing service is available in our writing service
ReplyDeleteI want to check the whole tutorial now. Will you help me with that, friend?
ReplyDeleteNice post thanks for share article.
ReplyDeleteAPK Editor Pro
appvalley vip