Created
May 10, 2022 03:13
-
-
Save jiachen247/feaf03ba333a13a48c5de9c656a69fbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
# 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