mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-06 22:34:18 +08:00
Free memory after removing
a node from a LinkedList or TreeNode.
This commit is contained in:
@ -33,6 +33,7 @@ int main() {
|
||||
PrintUtil::printTree(n1);
|
||||
// 删除结点 P
|
||||
n1->left = n2;
|
||||
delete P; // 释放内存
|
||||
cout << endl << "删除结点 P 后\n" << endl;
|
||||
PrintUtil::printTree(n1);
|
||||
|
||||
|
Reference in New Issue
Block a user