其他分享
首页 > 其他分享> > LeetCode98. Validate Binary Search Tree

LeetCode98. Validate Binary Search Tree

作者:互联网

题意

解法

代码


long long pre = LLONG_MIN;
bool isValidBST(TreeNode* root) {
    if (root == nullptr) return true;
    if (!isValidBST(root->left)) return false;
    if (root->val <= pre) return false;
    pre = root->val;
    return isValidBST(root->right);
}

标签:LeetCode98,Binary,return,val,long,升序,Validate,root,isValidBST
来源: https://www.cnblogs.com/Figure_at_a_Window/p/16417655.html