1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#include "lib/uthash/src/uthash.h"
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
using namespace std;
#define vvd(data) vector<vector<data>>
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ListNode *next) : val(x), next(next) {}
};
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode() : val(0), left(nullptr), right(nullptr) {}
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
TreeNode(int x, TreeNode *left, TreeNode *right)
: val(x), left(left), right(right) {}
};
class Node {
public:
int val;
vector<Node *> children;
Node() {}
Node(int _val) { val = _val; }
Node(int _val, vector<Node *> _children) {
val = _val;
children = _children;
}
};
#else //__cplusplus
struct ListNode {
int val;
struct ListNode *next;
};
struct TreeNode {
int val;
struct TreeNode *left;
struct TreeNode *right;
};
struct ListNode *listnode_create(int val);
void listnode_print(struct ListNode *head);
struct TreeNode *treenode_create(int val);
void treenode_print(struct TreeNode *root);
#define IS_ARRAY(value) \
(!__builtin_types_compatible_p(typeof((value)), typeof(&(value)[0])))
#define ARRAY_SIZE(array) \
(__builtin_choose_expr(IS_ARRAY((array)), \
sizeof((array)) / sizeof((array)[0]), (void)0))
#endif
|