一:题目
二:上码
/*** Definition for a binary tree node.* struct TreeNode {* int val;* TreeNode *left;* TreeNode *right;* TreeNode() : val(0), left(nullptr), right(nullptr) {}* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}* };*/
class Solution {
public:void epilogue(TreeNode* root,vector<int>& v) {if(root == NULL) return;epilogue(root->left,v);epilogue(root->right,v);v.push_back(root->val);}vector<int> postorderTraversal(TreeNode* root) {vector<int> ans;epilogue(root,ans);return ans;}
};