mirror of
https://github.com/krahets/hello-algo.git
synced 2024-12-25 02:36:29 +08:00
feat(codes/cpp/include/TreeNode.cpp): add 'parent' and 'height' field
This commit is contained in:
parent
e9996b37d6
commit
641cf74afc
1 changed files with 7 additions and 4 deletions
|
@ -11,10 +11,13 @@
|
|||
*
|
||||
*/
|
||||
struct TreeNode {
|
||||
int val;
|
||||
TreeNode *left;
|
||||
TreeNode *right;
|
||||
TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
|
||||
int val{};
|
||||
int height = 1;
|
||||
TreeNode *parent{};
|
||||
TreeNode *left{};
|
||||
TreeNode *right{};
|
||||
TreeNode() = default;
|
||||
explicit TreeNode(int x, TreeNode *parent = nullptr) : val(x), parent(parent) {}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue