Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1.  
  2.  
  3. void get_height(TreeNode *cur, height &h) {
  4. if (!cur) {
  5. h = 0;
  6. return;
  7. }
  8. int left_height, right_height;
  9. left_height = right_height = 0;
  10. get_height(cur->left, h);
  11. left_height = h;
  12. get_height(cur->right, h);
  13. right_height = h;
  14. h = 1 + std::max(left_height, right_height);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement