```
class Solution
{
public:
vector<int> postorderTraversal(TreeNode* root)
{
vector<int> res;
traverse(root, res);
return res;
}
void traverse(TreeNode* node, vector<int>& res)
{
if(NULL == node) return;
traverse(node->left, res);
traverse(node->right, res);
res.push_back(node->val);
}
};
```