Syntax problem. Not understanding

I’m not familiar with the syntax. I have problems in leetcode as well. Please code this solution so that I can understand the syntax. I am well aware of the logic.

Refer this:

vector<int>result;
int maxlevel=-1;

void helper(TreeNode* root,int level)
{
    if(root==NULL)
        return;
    if(level>maxlevel)
    {
        maxlevel=level;
        result.push_back(root->val);
    }
    helper(root->right,level+1);
    helper(root->left,level+1);
    return;
}

vector<int> rightSideView(TreeNode* root) 
{
 helper(root,0);
 return result;
}

This part I have understood fully and written as well. Please code the whole program including the main function. Do I have to make an object of the class or something in the main method. Please write the whole program. I just want to see the syntax

You will have to make a class for the nodes of a tree which will contain the data value with left and right pointer as you do in all tree questions.You will have to make a build tree function which will take the inputs and convert it to a tree. There is nothing extra in the implementation part. If you have watched the previous video, you will be able to do it on your own.
If you face problem in taking the inputs for the tree, you can refer this How to take input
Please try to implement it on your own. We cannot directly share the code.

So this is my updated code. Which seems fine to me. Just a question though, if I have to submit the solution on leetcode, only the solution class is to be written right, and not a single thing extra?

Yes in leetcode you just have to complete the function. So the code i have shared above is enough for that. You do not need to make any class and object.

Cool, thanks a lot for the help

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.