标签:pos logs tac null csharp public treenode res lis
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
标签:pos logs tac null csharp public treenode res lis
原文地址:http://www.cnblogs.com/asuran/p/7679747.html