| 49 | # self.right = None |
| 50 | |
| 51 | class Solution(object): |
| 52 | def isValidBST(self, root): |
| 53 | """ |
| 54 | :type root: TreeNode |
| 55 | :rtype: bool |
| 56 | """ |
| 57 | if not root: |
| 58 | return True |
| 59 | |
| 60 | self.prev = -float('inf') |
| 61 | |
| 62 | def inOrderTraversal(root): |
| 63 | |
| 64 | if root.left: |
| 65 | if inOrderTraversal(root.left) == -1: |
| 66 | return -1 |
| 67 | |
| 68 | if root.val <= self.prev: |
| 69 | return -1 |
| 70 | |
| 71 | self.prev = root.val |
| 72 | |
| 73 | if root.right: |
| 74 | if inOrderTraversal(root.right) == -1: |
| 75 | return -1 |
| 76 | if inOrderTraversal(root) == -1: |
| 77 | return False |
| 78 | return True |
nothing calls this directly
no outgoing calls
no test coverage detected