Last updated 2 years ago
vector<int> res; void fillInorder(TreeNode *A) { if(!A) return; res.push_back(A->val); fillInorder(A->left); fillInorder(A->right); } vector<int> Solution::preorderTraversal(TreeNode* A) { res.clear(); fillInorder(A); return res; }