✅C++|| Height and Depth  || Easy Solution
\nclass Solution {\npublic:\n    map<int,int> l,r,h;\n    int height(TreeNode *root)\n    {\n        if(!root) return 0;\n        \n        int lh = height(root
```\nclass Solution {\npublic:\n    map<int,int> l,r,h;\n    int height(TreeNode *root)\n    {\n        if(!root) return 0;\n        \n        int lh = height(root->left);\n        int rh = height(root->right);\n        \n        l[root->val] = lh;\n        r[root->val] = rh;\n        \n        return max(lh,rh)+1;\n    }\n    void solve(TreeNode *root,int maxa,int depth){\n        if(!root) return;\n        \n        h[root->val] = maxa;\n        \n        solve(root->left, max(maxa, depth+r[root->val]), depth+1);\n        solve(root->right, max(maxa, depth+l[root->val]),depth+1);\n    }\n    vector<int> treeQueries(TreeNode* root, vector<int>& queries) {\n        height(root);\n        solve(root->left, r[root->val], 1);\n        solve(root->right, l[root->val], 1);\n        \n        vector<int> ans;\n        \n        for(int i=0;i<queries.size();i++){\n            ans.push_back(h[queries[i]]);\n        }\n        \n        return ans;\n    }\n};\n```\n**Please upvote if it was helpful for you, thank you!**
['Tree', 'C']