Skip to content

Instantly share code, notes, and snippets.

@aburan28
Created January 30, 2023 17:17
Show Gist options
  • Save aburan28/889b8de528cae8c3a5eaa6a18f0db085 to your computer and use it in GitHub Desktop.
Save aburan28/889b8de528cae8c3a5eaa6a18f0db085 to your computer and use it in GitHub Desktop.
res = []
def inorder(root):
if not root:
return
inorder(root.left)
res.append(root.val)
inorder(root.right)
def preorder(root):
if not root:
return
preorder(root.left)
preorder(root.right)
res.append(root.val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment