Leetcode206. 反轉連結串列
阿新 • • 發佈:2021-02-11
技術標籤:Leetcode
class Solution {
public:
ListNode* reverseList(ListNode* head) {
ListNode* pre=nullptr;
ListNode* cur=head;
while(cur){
ListNode* next=cur->next;
cur->next=pre;
pre=cur;
cur=next;
}
return pre;
}
};