迭代 class Solution { public: ListNode* reverseList(ListNode* head) { if(!head)return head; auto temp=head; head=head->next; temp->next=nullptr; while(head){ auto h=head->next; head->next=temp; temp=head; head=h; } return temp; } };