剑指offer打卡 week3
时间:2021-09-07 15:37:36
收藏:0
阅读:11
35. 反转链表
https://www.acwing.com/problem/content/33/
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode* prev=NULL;
ListNode* cur=head;
while(cur){
auto next=cur->next;
cur->next=prev;
prev=cur;
cur=next;
}
return prev;
}
};
原文:https://www.cnblogs.com/0fflineboy/p/15235287.html
评论(0)