ListNode* reverseList(ListNode* head) {
ListNode*pre=NULL;
ListNode*post=NULL;
if(!head)return head;
post=head->next;
while(post){
head->next=pre;
pre=head;
head=post;
post=post->next;
}
head->next=pre;
return head;
}
反转链表
最新推荐文章于 2024-06-14 09:15:00 发布