<jupyter_start><jupyter_text>说明：    给定二叉树的根，返回其节点值的PostOrder遍历。后续：    递归解决方案很简单，您可以迭代吗？<jupyter_code>class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right
# postorder: left->right->Node
class Solution:
    def postorderTraversal(self, root: TreeNode):
        if not root:
            return []
        self.res = []
        self.helper(root)
        return self.res
    
    def helper(self, root):
        if not root:
            return 
        self.helper(root.left)
        self.helper(root.right)
        self.res.append(root.val)
# postorder: left->right->Node
# 迭代的方式
class Solution:
    def postorderTraversal(self, root: TreeNode):
        if not root:
            return []
        res = []
        nodes = [root]
        while nodes:
            n = nodes.pop()
            if n:
                res.insert(0, n.val)
                nodes.append(n.left)
                nodes.append(n.right)
        return res<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10919540229885058, 'fraction_numerical': 0.0019157088122605363, 'mean_word_length': 1.8167115902964959, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '397134', 'license': 'Apache-2.0', 'n_tokens_mistral': 357, 'n_tokens_neox': 366, 'n_words': 69, 'path': 'Tree/0830/145. Binary Tree Postorder Traversal.ipynb', 'repo_name': 'YuHe0108/Leetcode', 'size': '1044'}