/*
public class ListNode {
int val;
ListNode next = null;
ListNode(int val) { this.val = val; }
}*/
public class Solution {
public ListNode ReverseList(ListNode head) {
if(head == null || head.next == null) {
return head;
}
// 递归到最后节点
ListNode last = ReverseList(head.next);
// 最后节点指向倒数第二个节点head
head.next.next = head;
// 不需要指向最后节点了
head.next = null;
return last;
}
}