Free memory after removing

a node from a LinkedList or TreeNode.
This commit is contained in:
Yudong Jin
2023-01-02 19:53:55 +08:00
parent 6b02449f22
commit 410c5d6b62
20 changed files with 69 additions and 140 deletions

View File

@@ -311,7 +311,10 @@ comments: true
/* 出栈 */
int pop() {
int num = top();
ListNode *tmp = stackTop;
stackTop = stackTop->next;
// 释放内存
delete tmp;
stkSize--;
return num;
}