c_cpp 145. Binary Tree Postorder Traversal - DifficultyHard - 2018.9.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 145. Binary Tree Postorder Traversal - DifficultyHard - 2018.9.7相关的知识,希望对你有一定的参考价值。

//递归解法:
class Solution {
public:
    void pTra(TreeNode* root, vector<int> &vec) {
        if (root == NULL) return;
        pTra(root->left, vec);
        pTra(root->right, vec);
        vec.insert(vec.end(), root->val);
    }
    vector<int> postorderTraversal(TreeNode* root) {
        vector<int> result;
        pTra(root, result);
        return result;
    }
};

以上是关于c_cpp 145. Binary Tree Postorder Traversal - DifficultyHard - 2018.9.7的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode145. Binary Tree Postorder Traversal

leetcode 145. Binary Tree Postorder Traversal

145. Binary Tree Postorder Traversal

LeetCode145. Binary Tree Postorder Traversal 解题报告

145. Binary Tree Postorder Traversal

145. Binary Tree Postorder Traversal