<s> """<STR_LIT>""" <EOL> __author__ = '<STR_LIT>' <EOL> class TreeNode : <EOL> def __init__ ( self , x ) : <EOL> self . val = x <EOL> self . left = None <EOL> self . right = None <EOL> class Solution : <EOL> def isValidBST ( self , root ) : <EOL> """<STR_LIT>""" <EOL> if not root : <EOL> return True <EOL> if not self . isValidBST ( root . left ) : <EOL> return False <EOL> if not self . isValidBST ( root . right ) : <EOL> return False <EOL> if root . left : <EOL> if not self . get_largest ( root . left ) < root . val : <EOL> return False <EOL> if root . right : <EOL> if not root . val < self . get_smallest ( root . right ) : <EOL> return False <EOL> return True <EOL> def get_largest ( self , root ) : <EOL> """<STR_LIT>""" <EOL> if not root . right : <EOL> return root . val <EOL> return self . get_largest ( root . right ) <EOL> def get_smallest ( self , root ) : <EOL> """<STR_LIT>""" <EOL> if not root . left : <EOL> return root . val <EOL> return self . get_smallest ( root . left ) </s>
