一种递归的实现方式总结如下:
class Solution
{
public:
ListNode *reverseList(ListNode *head)
{
if (head == NULL || head->next == NULL)
{
return head;
}
ListNode *pcur = reverseList(head->next);
head->next->next = head;
head->next = NULL;
return pcur;
}
}