1. 程式人生 > 其它 >Leetcode206. 反轉連結串列

Leetcode206. 反轉連結串列

技術標籤: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; } };