Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
class Solution {
vector<int> postorderTraversal(TreeNode* root) {
vector<int> res;
rec(res, root);
return res;
void rec(vector<int> &res, TreeNode* root){
if(root == NULL) return;
rec(res, root->left);
rec(res, root->right);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment