diff --git a/cpp/2305/data_structure.h b/cpp/2305/data_structure.h new file mode 100644 index 0000000..27ce1ba --- /dev/null +++ b/cpp/2305/data_structure.h @@ -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 +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