You are viewing a single comment's thread. Return to all comments →
Minor variation. Four assignments in loop instead of 5. Same algorithm, just eliminate a couple of variables.
Node Reverse(Node head) { if(head==null )return null; head.prev = head.next; head.next = null; while(head.prev!=null){ head = head.prev; Node temp = head.next; head.next = head.prev; head.prev = temp; } return head; }
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 →
Minor variation. Four assignments in loop instead of 5. Same algorithm, just eliminate a couple of variables.