1 public ListNode reverseList(ListNode head) { 2 if (head == null || head.next == null) return head; 3 ListNode p = reverseList(head.next); 4 head.next.next = head; 5 head.next = null; 6 return p; 7 }
1 public ListNode reverseList(ListNode head) { 2 if (head == null || head.next == null) return head; 3 ListNode p = reverseList(head.next); 4 head.next.next = head; 5 head.next = null; 6 return p; 7 }