# Definition for a binary tree node.
# class TreeNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
class Solution:  
    def isValidBST(self, root):  
    	return self.min_max_search(root,-2**31-1,2**31)#注意测试样例
    def min_max_search(self, root, min, max):
    	if root is None:
    		return True
    	return root.val < max and root.val > min and self.min_max_search(root.left,min,root.val) and self.min_max_search(root.right,root.val,max)
de31fb93ab79f3c76fff8fb2d32263e5ed10ae3d
<mask token>

class Solution:
    <mask token>
    <mask token>

class Solution:
    <mask token>

    def min_max_search(self, root, min, max):
        if root is None:
            return True
        return root.val < max and root.val > min and self.min_max_search(root
            .left, min, root.val) and self.min_max_search(root.right, root.
            val, max)

class Solution:

    def isValidBST(self, root):
        return self.min_max_search(root, -2 ** 31 - 1, 2 ** 31)

    def min_max_search(self, root, min, max):
        if root is None:
            return True
        return root.val < max and root.val > min and self.min_max_search(root
            .left, min, root.val) and self.min_max_search(root.right, root.
            val, max)

# Definition for a binary tree node.
# class TreeNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None
class Solution:  
    def isValidBST(self, root):  
    	return self.min_max_search(root,-2**31-1,2**31)#注意测试样例
    def min_max_search(self, root, min, max):
    	if root is None:
    		return True
    	return root.val < max and root.val > min and self.min_max_search(root.left,min,root.val) and self.min_max_search(root.right,root.val,max)