标签:
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ /* 二叉树的后序遍历序列 */ class Solution { public: vector<int> res; void dfs(TreeNode *root){ if(!root) return; dfs(root->left); dfs(root->right); res.push_back(root->val); } vector<int> postorderTraversal(TreeNode *root) { dfs(root); return res; } };
Binary Tree Postorder Traversal
标签:
原文地址:http://www.cnblogs.com/llei1573/p/4342898.html