Skip to content

Instantly share code, notes, and snippets.

@Khamies
Created March 13, 2023 06:28
Show Gist options
  • Select an option

  • Save Khamies/04238f43fa290633e087bf32b37e8c2f to your computer and use it in GitHub Desktop.

Select an option

Save Khamies/04238f43fa290633e087bf32b37e8c2f to your computer and use it in GitHub Desktop.
def is_symmetric_BT(root):
def check(left, right):
if not left and not right:
return True
if not left or not right:
return False
if left.val != right.val:
return False
return check(left.left, right.right) and check(left.right, right.left)
return check(root.left, root.right)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment