class Solution {
public:
bool isValidBST(TreeNode *root) {
return judge(root,INT_MIN,INT_MAX);
}
bool judge(TreeNode*root,int low,int high)
{
if(root==NULL)return true;
return root->val>low&&root->val<high&&judge(root->left,low,root->val)&&judge(root->right,root->val,high);
}
};
网友评论