PayPal interview question

reverse Linked List

Interview Answers

Anonymous

Apr 3, 2012

gave a recursive solution, but was not satisfied with my answer

Anonymous

Mar 20, 2016

ListNode reverse(ListNode head) { ListNode newHead = null; while(head != null) { ListNode nextNode = head.next; head.next = newHead; newHead = head; head = nextNode; } return newHead; }