首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏calmound

    Binary Tree Postorder Traversal

    TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: void PostOrder =NULL) { PostOrder(root->left,vec); PostOrder(root->right,vec); } } vector<int> postorderTraversal(TreeNode *root) { vector<int>vec; PostOrder

    62180发布于 2018-04-17
  • 来自专栏全栈程序员必看

    Binary Tree Postorder Traversal — LeetCode

    原题链接: http://oj.leetcode.com/problems/binary-tree-postorder-traversal/ 跟 Binary Tree Inorder Traversal

    35710编辑于 2022-11-17
  • 来自专栏搬砖记录

    33 N-ary Tree Postorder Traversal

    题目 Given an n-ary tree, return the postorder traversal of its nodes’ values. 再遍历根节点 解答 class Solution { // 存放结果 List<Integer> list = new ArrayList<>(); public List<Integer> postorder null) return list; // 递归遍历其他节点 for(Node node: root.children) postorder

    42320发布于 2021-08-18
  • 来自专栏皮皮星球

    Binary Tree Postorder Traversal

    Binary Tree Postorder Traversal Given a binary tree, return the postorder traversal of its nodes' values

    54210发布于 2020-09-23
  • 来自专栏计算机视觉与深度学习基础

    Leetcode 145 Binary Tree Postorder Traversal

    Given a binary tree, return the postorder traversal of its nodes' values.

    51580发布于 2018-01-12
  • 来自专栏Reck Zhang

    LeetCode 0145 - Binary Tree Postorder Traversal

    Binary Tree Postorder Traversal Desicription Given a binary tree, return the postorder traversal of its

    33220发布于 2021-08-11
  • 来自专栏赵俊的Java专栏

    LeetCode 590 N-ary Tree Postorder Traversal

    val = _val; children = _children; } }; */ class Solution { public List<Integer> postorder } }; */ class Solution { List<Integer> list = new ArrayList<>(); public List<Integer> postorder return list; } for (Node child : root.children) { postorder return list; } } Runtime: 1 ms, faster than 100.00% of Java online submissions for N-ary Tree Postorder Memory Usage: 48.2 MB, less than 40.66% of Java online submissions for N-ary Tree Postorder Traversal

    57010发布于 2019-12-30
  • 来自专栏SnailTyan

    Leetcode145——Binary Tree Postorder Traversal

    问题描述 Given a binary tree, return the postorder traversal of its nodes’ values.

    40550发布于 2019-05-26
  • 来自专栏尾尾部落

    Construct Binary Tree from Inorder and Postorder Traversal

    链接:https://leetcode.com/problems/construct-binary-tree-from-inorder-and-postorder-traversal/description Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of a , 0, postorder.length-1, inorderMap); } public TreeNode buildTree(int[] inorder, int iLeft, >iRight || pLeft>pRight) return null; TreeNode cur = new TreeNode(postorder[pRight , i+1, iRight, postorder, pLeft+i-iLeft, pRight-1, inorderMap); return cur; } }

    62320发布于 2018-09-04
  • 来自专栏乐行僧的博客

    PAT(甲级)1138.Postorder Traversal(25)

    PAT 1138.Postorder Traversal(25) Suppose that all the keys in a binary tree are distinct positive integers Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder 输出格式: For each test case, print in one line the first number of the postorder traversal sequence of (node* root){ if(root){ postorder(root->lchild); postorder(root->rchild); pre[i]);} for(int i=1; i<=n; ++i){scanf("%d", &mid[i]);} node* root = build(1, n, 1, n); postorder

    34030编辑于 2022-02-25
  • 来自专栏给永远比拿愉快

    Leetcode: Construct Binary Tree from Inorder and Postorder Traversal

    题目: Given inorder and postorder traversal of a tree, construct the binary tree. ) { if (postorder.empty()) return nullptr; TreeNode *root = makeNode(inorder.begin (), inorder.end(), postorder.begin(), postorder.end()); return root; } }; Java参考代码: /** , postBegin + leftSize); root.right = makeNode(inorder, index + 1, inEnd, postorder, postBegin , postorder, 0, postorder.length); return root; } }

    56620发布于 2019-01-22
  • 来自专栏米扑专栏

    【leetcode】Construct Binary Tree from Inorder and Postorder Traversal

    Question:  Given inorder and postorder traversal of a tree, construct the binary tree. [postorder[post_offset]]; root->right = buildTreeInOrder(postorder, post_offset-1, inorder, in_offset, in_offset-i); root->left = buildTreeInOrder(postorder, post_offset-(in_offset-i)-1 , postorder.size()-1, inorder, inorder.size()-1, postorder.size()); } }; 参考推荐: Construct Binary Tree from Inorder and Postorder Traversal

    52530发布于 2019-02-19
  • 来自专栏学习日记

    Binary Tree Postorder Traversal.go

    版权声明:原创勿转 https://blog.csdn.net/anakinsun/article/details/88992726

    44130发布于 2019-04-12
  • 来自专栏SnailTyan

    N-ary Tree Postorder Traversal

    val = _val; children = _children; } }; */ class Solution { public: vector<int> postorder val = _val; children = _children; } }; */ class Solution { public: vector<int> postorder reverse(result.begin(), result.end()); } }; Reference https://leetcode.com/problems/n-ary-tree-postorder-traversal

    41820发布于 2019-05-25
  • 来自专栏全栈程序员必看

    Construct Binary Tree from Inorder and Postorder Traversal「建议收藏」

    Given inorder and postorder traversal of a tree, construct the binary tree. For example, given inorder = [9,3,15,20,7] postorder = [9,15,7,20,3] Return the following binary tree ) { if (null == postorder || postorder.length < 1) { return null; } return buildTree(inorder, 0, inorder.length - 1, postorder, postorder.length - 1); } public TreeNode buildTree(int[] inorder, int start, int end, int[] postorder, int idx) {

    26410编辑于 2022-08-04
  • 来自专栏计算机视觉与深度学习基础

    Leetcode 106 Construct Binary Tree from Inorder and Postorder Traversal

    Given inorder and postorder traversal of a tree, construct the binary tree. +1,ie); return root; } TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder ) { return dfs(postorder,0,inorder.size()-1,inorder,0,inorder.size()-1); } };

    75560发布于 2018-01-12
  • 来自专栏XINDOO的专栏

    Leetcode Binary Tree Postorder Traversal(面试题推荐)

    此题来自leetcode https://oj.leetcode.com/problems/binary-tree-postorder-traversal/ Given a binary tree , return the postorder traversal of its nodes' values.

    42210发布于 2021-01-21
  • 来自专栏Reck Zhang

    LeetCode 0106 - Construct Binary Tree from Inorder and Postorder Traversal

    Construct Binary Tree from Inorder and Postorder Traversal Desicription Given inorder and postorder traversal private: TreeNode* generateTree(int postStart, int postEnd, int inStart, int inEnd, vector<int>& postorder int inIndex = 0; for(int i = inStart; i <= inEnd; i++) { if(inorder[i] == postorder , inorder); root->right = generateTree(postEnd-inEnd+inIndex, postEnd-1, inIndex+1, inEnd, postorder ) { return generateTree(0, postorder.size()-1, 0, inorder.size()-1, postorder, inorder);

    25230发布于 2021-08-11
  • 来自专栏SnailTyan

    Construct Binary Tree from Inorder and Postorder Traversal

    NULL) {} * }; */ class Solution { public: TreeNode* buildTree(vector<int>& inorder, vector<int>& postorder ) { int current = inorder.size() - 1; return build(postorder, inorder, current, 0, postorder.size () - 1); } private: TreeNode* build(vector<int>& postorder, vector<int>& inorder, int& current if(current == -1 || start > end) { return nullptr; } int value = postorder , inorder, current, index + 1, end); node->left = build(postorder, inorder, current, start, index

    39710发布于 2019-05-25
  • 来自专栏JNing的专栏

    Construct Binary Tree from Inorder and Postorder Traversal

    Problem Given inorder and postorder traversal of a tree, construct the binary tree. For example, given inorder = [9,3,15,20,7] postorder = [9,15,7,20,3] Return the following binary tree ): if not len(postorder): return None root = TreeNode(postorder[-1]) idx = inorder.index(root.val) root.left = self.buildTree(inorder[ : idx], postorder[ : idx]) root.right = self.buildTree(inorder[idx+1 : ], postorder[idx : -1]) return root

    43030发布于 2019-02-25
领券