class Solution {
public:
ListNode* ReverseList(ListNode* pHead) {
if(pHead==NULL) return NULL;
ListNode *pre=NULL;
ListNode *next=NULL;
while(pHead!=NULL){
next=pHead->next;
pHead->next=pre;
pre=pHead;
pHead=next;
}
return pre;
}
};
链表逆置
最新推荐文章于 2023-09-17 10:12:18 发布