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