#include<iostream>
using namespace std;
class solution{
public:
ListNode reverse(ListNode* head){
ListNode *dummpy = new ListNode(-1);
ListNode *pre = head;
ListNode *cur = head->next;
while(cur->next !=NULL){
ListNode *tmp = cur->next;
cur->next = pre;
pre->next = tmp;
cur = tmp;
head = cur;
}
return dumppy->next;
}
}
leetcode reverse list
最新推荐文章于 2022-10-08 18:10:16 发布