Time(100%)|Memo(100%)|preorder , Reverse PreOrder (Node,Right,Left)
The explantion is for preorder we will be storing the maximum height we till its predecessor.\nsame goes to the reverse preorder. and we are stroing the values 
The explantion is for preorder we will be storing the maximum height we till its predecessor.\nsame goes to the reverse preorder. and we are stroing the values in an array\n```\nclass Solution {\npublic:\n\n    int dp[100001]={0};\n    int maxi1=0,maxi2=0;\n    void dfs(TreeNode *root,int height=0)\n    {\n        if(root==NULL)\n            return;\n        dp[root->val]=max(maxi2,dp[root->val]);  \n        maxi2=max(maxi2,height);      \n        dfs(root->left,height+1);\n        dfs(root->right,height+1);          \n    }\n    \n    void reversedfs(TreeNode *root,int height=0)\n    {\n        \n        if(root==NULL)\n        return ;        \n        dp[root->val]=max(maxi1,dp[root->val]);\n        maxi1=max(maxi1,height);\n        reversedfs(root->right,height+1);\n        reversedfs(root->left,height+1); \n        return;       \n    }\n\n    vector<int> treeQueries(TreeNode* root, vector<int>& queries) \n    {\n        vector<int>ans;\n        dfs(root,0);\n        reversedfs(root,0);\n          \n        for(int i=0;i<queries.size();i++)\n        {\n            ans.push_back(dp[queries[i]]);\n        }\n        return ans;\n    }\n};\n```
['Dynamic Programming', 'Recursion']