Recursive and simple cpp solution


#1

‘’’

void inorder(TreeNode* root,vector &vec)
{

    if(root->left!=NULL){
        inorder(root->left,vec);     
    }
    vec.push_back(root->val);
    if(root->right!=NULL) {
        inorder(root->right,vec);
    }
    return;

}

vector Solution::inorderTraversal(TreeNode* A) {

if(!A) return {};
vector<int> v;
inorder(A,v);
return v;

}

‘’’