一、题目描述

二、算法原理

三、代码实现
class Solution {
public:
ListNode* reverseList(ListNode* head)
{
if(head==nullptr) return nullptr;
if(head->next==nullptr) return head;
ListNode* newhead=reverseList(head->next);
head->next->next=head;
head->next=nullptr;
return newhead;
}
};