Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

recursive reverse linked list

public ListNode reverseList(ListNode head) {
    if (head == null || head.next == null) return head;
    ListNode p = reverseList(head.next);
    head.next.next = head;
    head.next = null;
    return p;
}
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #recursive #reverse #linked #list
ADD COMMENT
Topic
Name
6+6 =