You are viewing a single comment's thread. Return to all comments →
C++, recursion.
int height(Node* root) { if (!root || (!root->left && !root->right)) return 0; return 1 + std::max( height(root->left), height(root->right) ); }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Tree: Height of a Binary Tree
You are viewing a single comment's thread. Return to all comments →
C++, recursion.