首页 > 代码库 > Binary Tree Postorder Traversal

Binary Tree Postorder Traversal

 1 class Solution { 2 public: 3     vector<int> postorderTraversal(TreeNode *root) { 4         if(root->left == NULL && root->right == NULL) 5         { 6             v1.push_back(root->val); 7             return v1; 8         } 9         if(root->left != NULL)10         postorderTraversal(root->left);11         if(root->right != NULL)12         postorderTraversal(root->right);13         v1.push_back(root->val);14         return v1;15     }16 };