class Solution {
public ListNode reverseList(ListNode head) {
if(head==null||head.next==null){
return head;
}
ListNode node=reverseList(head.next);
head.next.next=head;
head.next=null;
return node;
}
}
反转链表递归实现
最新推荐文章于 2024-05-02 09:08:07 发布