【问题描述】
Reverse a singly linked list.
【思路】
递归
public ListNode reverseList(ListNode head) {
if (head == null) {
return null;
}
if (head.next == null) {
return head;
}
ListNode temp = head.next;
ListNode n = reverseList(temp);
head.next = null;
n.next = head;
return n;
}