给出一棵二叉树,返回其节点值的后序遍历。 您在真实的面试中是否遇到过这个题? Yes 哪家公司问你的这个题? Airbnb Alibaba Amazon Apple Baidu Bloomberg Cisco Dropbox Ebay Facebook Google Hulu Intel Linkedin Microsoft NetEase Nvidia Oracle Pinterest Snapchat Tencent Twitter Uber Xiaomi Yahoo Yelp Zenefits 感谢您的反馈 样例 给出一棵二叉树 {1,#,2,3}, 1 \ 2 / 3 返回 [3,2,1] 挑战 你能使用非递归实现么? 标签 Expand 递归 二叉树 二叉树遍历 相关题目 Expand 1 (recursion),(binary-tree),(binary-tree-traversal),(non-recursion) 容易 二叉树的前序遍历 40 % /** * Definition of TreeNode: * public class TreeNode { * public int val; * public TreeNode left, right; * public TreeNode(int val) { * this.val = val; * this.left = this.right = null; * } * } */ public class Solution { /** * @param root: The root of binary tree. * @return: Postorder in ArrayList which contains node values. */ ArrayList<Integer> result = new ArrayList<>(); public ArrayList<Integer> postorderTraversal(TreeNode root) { // write your code here if(root==null) return result; if(root.left!=null){ postorderTraversal(root.left); } if(root.right!=null){ postorderTraversal(root.right); } result.add(root.val); return result; } }