class Solution { public List<Integer> postorderTraversal(TreeNode root) { Stack<TreeNode> stack=new Stack<TreeNode>(); List<Integer> res=new ArrayList<Integer>(); while(root!=null||!stack.isEmpty()) { while(root!=null) { res.add(0, root.val); stack.push(root); root=root.right; } root=stack.pop().left; } return res; } }
145. Binary Tree Postorder Traversal
原文:http://www.cnblogs.com/asuran/p/7679747.html