Easy Understand C++ solution


  • -3
    M

    class Solution {

    public:

    void Inorder_traversal(vector<int>& rtn, TreeNode * root){
        if(root == NULL);
        else{
            Inorder_traversal(rtn,root->left);
            rtn.push_back(root->val);
            Inorder_traversal(rtn,root->right);
        }
    } 
    vector<int> inorderTraversal(TreeNode* root) {
        vector<int>rtn(0);
        Inorder_traversal(rtn,root);
        return rtn;
    }
    

    };


Log in to reply
 

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