class Solution{ public: //Function to find the height of a binary tree. int depth(Node* temp) { if(temp==NULL) return 0; int lh=depth(temp->left); int rh=depth(temp->right); return 1+max(lh,rh); } int height(struct Node* node){ int ans=depth(node); return ans; // code here } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter