WA for limit value


  • 0
    B

    class Solution {
    #define ll long long
    public:
    bool isValidBST(TreeNode* root) {
    return fun(root,LLONG_MIN,LLONG_MAX);
    }
    bool fun(TreeNode* root,ll min,ll max)
    {
    if(root==NULL)
    return 1;
    if(root->val<min||root->val>max)
    return 0;
    return fun(root->left,min,root->val-1)&&fun(root->right,root->val+1,max);

    }
    

    };


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.