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