eBay Interview Question

Reverse a Linked List Algo for Binary tree Lowest Common Ancestor

Interview Answer

Anonymous

Oct 20, 2014

Recursive way to reverse a linked list. public static Node recursive(Node head){ if(head==null) return null; if(head.next==null) return head; Node second = head.next; head.next=null; Node reverse=recursive(second); second.next=head; return reverse; }