feat(codes/cpp/include/TreeNode.cpp): add 'parent' and 'height' field

This commit is contained in:
mgisr 2022-12-03 17:17:58 +08:00
parent e9996b37d6
commit 641cf74afc

View File

@ -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) {}
};
/**