Height of tree

PHOTO EMBED

Sat Jul 09 2022 18:38:31 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

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 
    }
};
content_copyCOPY

https://practice.geeksforgeeks.org/problems/height-of-binary-tree/1/