We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent af1d46c commit edabe77Copy full SHA for edabe77
validate-binary-search-tree/printjin-gmailcom.py
@@ -0,0 +1,14 @@
1
+class Solution:
2
+ def isValidBST(self, root):
3
+ prev = None
4
+ def inorder(node):
5
+ nonlocal prev
6
+ if not node:
7
+ return True
8
+ if not inorder(node.left):
9
+ return False
10
+ if prev is not None and node.val <= prev:
11
12
+ prev = node.val
13
+ return inorder(node.right)
14
+ return inorder(root)
0 commit comments