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.
publicstaticDoublyLinkedListNodereverse(DoublyLinkedListNodellist){// Write your code hereDoublyLinkedListNodecurr=llist;DoublyLinkedListNodetemp=null;if(llist==null||llist.next==null)returnllist;while(curr!=null){temp=curr.prev;curr.prev=curr.next;curr.next=temp;curr=curr.prev;}if(temp!=null)llist=temp.prev;returnllist;}
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 →
JAVA: Here is my resolution for this problem: