根据二叉搜索树性质验证:中序遍历序列有序
class Solution {
public:
long tmp = LONG_MIN;
bool isValidBST(TreeNode* root) {
if(root == nullptr) return true;
if (isValidBST(root->left)) {
if (tmp < root->val) {
tmp = root->val;
return isValidBST(root->right);
}
}
return false;
}
};