单链表结构:
class ListNode{
int val;
ListNode next;
ListNode(int value){
this.val=value;
}
}
答案:
ListNode reverse(ListNode head) {
if (head.next == null) return head;
ListNode last = reverse(head.next);
head.next.next = head;
head.next = null;
return last;
}
https://blog.csdn.net/qq_37373722/article/details/106106221
https://zhuanlan.zhihu.com/p/86745433