Open Mgaurav01 opened 2 years ago
class Solution { public: void reversePreOrder(TreeNode* root , vector &ans , int l) { if(!root) return ;
if(l == ans.size()) ans.push_back(root->val); reversePreOrder(root->right , ans , l + 1); reversePreOrder(root->left , ans , l + 1); } vector<int> rightSideView(TreeNode* root) { vector<int>ans; reversePreOrder(root,ans ,0); return ans; }
};
tq
class Solution { public: void reversePreOrder(TreeNode* root , vector &ans , int l)
{
if(!root) return ;
};