<commit_before>/*
 * Written by <NAME>
 * <EMAIL>
 */

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
    bool isValidBST(TreeNode* root, long l, long r)
    {
        if(root == NULL)
            return true;
        
        if(root->val <= l || root->val >= r)
            return false;
        
        return (isValidBST(root->left, l, root->val) && isValidBST(root->right, root->val, r));
    }
public:
    bool isValidBST(TreeNode* root) {
        return isValidBST(root, LONG_MIN, LONG_MAX);
    }
};<commit_msg>98. Validate Binary Search Tree - One more solution added<commit_after>/*
 * Written by <NAME>
 * <EMAIL>
 */

/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
    bool isValidBST(TreeNode* root, long l, long r)
    {
        if(root == NULL)
            return true;
        
        if(root->val <= l || root->val >= r)
            return false;
        
        return (isValidBST(root->left, l, root->val) && isValidBST(root->right, root->val, r));
    }
public:
    bool isValidBST(TreeNode* root) {
        return isValidBST(root, LONG_MIN, LONG_MAX);
    }
};

//One more solution with inorder traversal
class Solution {
    void isValidBST(TreeNode* root, vector<int>& memory)
    {
        if(root == NULL)
            return;
        
        isValidBST(root->left, memory);
        memory.push_back(root->val);
        isValidBST(root->right, memory);
    }
public:
    bool isValidBST(TreeNode* root) {
        
        if(root == NULL)
            return true;
        
        vector<int> memory;
        isValidBST(root, memory);
        
        for(int i = 1; i < memory.size(); i++)
            if(memory[i] <= memory[i-1])
                return false;
        
        return true;
    }
};
{'fraction_non_alphanumeric': 0.14223300970873787, 'fraction_numerical': 0.001941747572815534, 'mean_word_length': 1.9442857142857144, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568682', 'n_tokens_mistral': 683, 'n_tokens_neox': 675, 'n_words': 169}