LeetCode - Binary Tree Postorder Traversal

Posted 朽木の半夏

tags:

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

/**
 * 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>fc;
    void dfs(TreeNode* fe){
        if(fe==NULL)return ;
            dfs(fe->left);
            dfs(fe->right);
        fc.push_back(fe->val);
    }
   
    vector<int> postorderTraversal(TreeNode* root) {
        dfs(root);
        return fc;
    }
};

























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

[Leetcode] Binary tree-- 606. Construct String from Binary Tree

[Leetcode] Binary search tree --Binary Search Tree Iterator

Leetcode[110]-Balanced Binary Tree

[Leetcode] Binary tree -- 501. Find Mode in Binary Search Tree

[Lintcode]95. Validate Binary Search Tree/[Leetcode]98. Validate Binary Search Tree

LeetCode 110. Balanced Binary Tree 递归求解