199. 二叉树的右视图
 
class Solution {
public:
    
vector<int> rightSideView(TreeNode* root) {
        
vector<int> res;
        rSVhelp(root,res,
0);
        
return res;
    }
    
void rSVhelp(TreeNode *r,
vector<int> &res,
int depth){
        
if(r==NULL) 
return;
        
if(depth+
1>res.size()) res.resize(depth+
1);
        res[depth]=r->val;
        rSVhelp(r->left,res,depth+
1);
        rSVhelp(r->right,res,depth+
1);
    }
};