My C method in the question


  • 0
    R

    int *rightSideView(struct TreeNode *root, int *n) {
    if(root->right!=NULL)
    {
    rightSideView(root->right,n++);
    }
    else if(root->left!=NULL)
    {
    rightSideView(root->left,n++);
    }
    else
    {
    *n=root->val;
    n--;
    }
    return n;
    }


Log in to reply
 

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