This commit is contained in:
Eatswap 2023-05-02 09:54:01 +08:00
parent dbb28499e4
commit 477e490bb4
Signed by: Eatswap
GPG Key ID: BE661106A1F3FA0B
1 changed files with 28 additions and 0 deletions

28
cpp/2305/data_structure.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef LEETCODE_CPP_DATA_STRUCTURE_H
#define LEETCODE_CPP_DATA_STRUCTURE_H
struct ListNode {
int val;
ListNode* next;
explicit ListNode(int x = 0, ListNode* next = nullptr) : val(x), next(next) {}
};
ListNode* construct(int x) {
return new ListNode(x);
}
template<typename... Ts>
ListNode* construct(int x, Ts... xs) {
return new ListNode(x, construct(xs...));
}
struct TreeNode {
int val;
TreeNode* left;
TreeNode* right;
explicit TreeNode(int x, TreeNode* left = nullptr, TreeNode* right = nullptr) : val(x), left(left), right(right) {}
};
#endif //LEETCODE_CPP_DATA_STRUCTURE_H