1 2 3 4 5 6 7 8 9 10 11 12 13 14
| vector<int> inorderTraversal(TreeNode* root) { vector<int> chain = {}; inorderTraversalRecur(root, &chain); return chain; }
void inorderTraversalRecur(TreeNode* root, vector<int>* chain) { if (!root) { return; } inorderTraversalRecur(root->left, chain); chain->push_back(root->val); inorderTraversalRecur(root->right, chain); }
|