首页 > 学院 > 开发设计 > 正文

145. Binary Tree Postorder Traversal

2019-11-08 03:20:43
字体:
来源:转载
供稿:网友

想不懂为什么是hard。。。

/** * 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 {public: vector<int>ve; void posto(TreeNode* root){ if(root == NULL) return ; posto(root -> left); posto(root -> right); ve.push_back(root -> val); } vector<int> postorderTraversal(TreeNode* root) { posto(root); return ve; }};
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表