Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void get_height(TreeNode *cur, height &h) {
- if (!cur) {
- h = 0;
- return;
- }
- int left_height, right_height;
- left_height = right_height = 0;
- get_height(cur->left, h);
- left_height = h;
- get_height(cur->right, h);
- right_height = h;
- h = 1 + std::max(left_height, right_height);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement