You are viewing a single comment's thread. Return to all comments →
Here's a four line solution using recursion.
static DoublyLinkedListNode reverse(DoublyLinkedListNode curr) { DoublyLinkedListNode temp = curr.next; curr.next = curr.prev; curr.prev = temp; return temp == null ? curr : reverse(temp); }
Good Logic! It helped alot! Thank You!
beautiful!
Neat solution. Loved it !
Brilliant
hey, can you explain 3,4 line. i don't understand, why you use this.
you solution is the best
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Reverse a doubly linked list
You are viewing a single comment's thread. Return to all comments →
Here's a four line solution using recursion.
Good Logic! It helped alot! Thank You!
beautiful!
Neat solution. Loved it !
Brilliant
hey, can you explain 3,4 line. i don't understand, why you use this.
you solution is the best