Skip to content

Commit 45e928f

Browse files
committed
feat(cpp): add delete method
1 parent 25c67be commit 45e928f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cpp/precompiled/ListNode.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
#ifndef LISTNODE_H
55
#define LISTNODE_H
66

7-
#include <iostream>
87
#include <vector>
9-
#include <tuple>
108
#include <functional>
119
#include <optional>
1210

@@ -25,6 +23,9 @@ struct ListNode{
2523
static ListNode* arrayToListNode(const std::vector<int> &arr);
2624
static std::vector<ListNode *> arraysToLinkedList(const std::vector<std::vector<int>> &arrList);
2725
static std::vector<int> listNodeToArray(ListNode *node);
26+
~ListNode() {
27+
delete next; //
28+
}
2829
};
2930

3031
#endif // LISTNODE_H

0 commit comments

Comments
 (0)