Easy solution in C++


  • 0
    N
    class Solution {
    public:
        vector<int> res = {};
        vector<int> inorderTraversal(TreeNode* root) {
            if(!root) return res;
            traver(root);
            return res;
        }
        void traver(TreeNode* root){
            if(root->left) traver(root->left);
            res.push_back(root->val);
            if(root->right) traver(root->right);
        }
    };
    

Log in to reply
 

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