daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top