My solution code


  • 0
    V
    class Solution {
    private:
        vector<int> preOut;
    public:
        vector<int> preorderTraversal(TreeNode* root) {
            if( !root )
                return vector<int>();
            preOut.push_back( root->val );
            preorderTraversal( root->left );
            preorderTraversal( root->right );
            return preOut;
        }
    };

Log in to reply
 

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