Skip to content

Instantly share code, notes, and snippets.

@alxfv
Last active July 26, 2019 12:47
Show Gist options
  • Save alxfv/849f14ff6675727978221beb04c1d469 to your computer and use it in GitHub Desktop.
Save alxfv/849f14ff6675727978221beb04c1d469 to your computer and use it in GitHub Desktop.
def isValid(node, floor, ceiling):
if not node:
return True
if not floor < node.val < ceiling:
return False
return isValid(node.left, floor, node.val) and isValid(node.right, node.val, ceiling)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment