Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jiachen247/feaf03ba333a13a48c5de9c656a69fbc to your computer and use it in GitHub Desktop.
Save jiachen247/feaf03ba333a13a48c5de9c656a69fbc to your computer and use it in GitHub Desktop.
"""
# Definition for a Node.
class Node(object):
def __init__(self, val=None, children=None):
self.val = val
self.children = children
"""
class Solution(object):
def postorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""
result = []
if root is None:
return result
for child in root.children:
result += self.postorder(child)
result.append(root.val)
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment