Why it give error like void declare


  • 0
    A
    void rightview_tree(Node *root, int level,int *max_level,vector<int> &v)
    {
        if(root==NULL)
            return ;
        if(level > *max_level)
        {
            v.push_back(root->val);
            *max_level=level;
        }
        rightview_tree(root->right,level+1,max_level,v);
        rightview_tree(root->left,level+1,max_level,v);
    }
    class Solution {
    public:
        vector<int> rightSideView(TreeNode* root) {
            
            int level_max=0;
            vector<int> v;
            rightview_tree(root,1,&max_level,v);
            return v;
        }
    };

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.