【C++ Primer 】第十二章、 内存管理 思维导图 笔记

发布于:2023-01-04 ⋅ 阅读:(159) ⋅ 点赞:(0)

在这里插入图片描述

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 *//**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 *//**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 *//**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 *//**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 *//**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
class Solution {
public:
    ListNode* reverseList(ListNode* head) {
        ListNode* cur = head;
        ListNode* pre = nullptr;
        while (cur != nullptr ) {
            ListNode* tmp = cur-> next;
            cur->next  = pre;
            pre = cur;
            cur = tmp;
        }
        return pre; // cur 最后为 null 退出
    }
};