6ms clean c solution

  • 0
    // (min, max)
    bool isValidBSTHelper(struct TreeNode* root, long long int min, long long int max) {
        if(root) {
                return isValidBSTHelper(root->left, min, root->val) && isValidBSTHelper(root->right, root->val, max);
                return false;
        } else
            return true;
    bool isValidBST(struct TreeNode* root) {
        return isValidBSTHelper(root, -100000000000, 100000000000);

Log in to reply

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